[gambit-list] destructuring bind define-type

lowly coder lowlycoder at huoyanjinjing.com
Tue Jun 2 01:07:36 EDT 2009


macro almost there :-)

given (define-type point x y z)

if at run time, I have the symbol "point", is there anyway that I can make
that will return me the name of the fields, i.e. '(x y z)? I'd rather have
this than all functions that start with point-* since I also define some of
them myself, like point-+ point-scale, ...

Thanks!

On Mon, Jun 1, 2009 at 9:45 PM, David Rush <kumoyuki at gmail.com> wrote:

> 2009/6/2 lowly coder <lowlycoder at huoyanjinjing.com>:
> > are there any amcros that play well with destructuring bind of
> define-type's
> > ? I just want to check to see if there's a pre-existing solution before
> > re-inventing my own.
> >
> > I find myself writing way too much code of the form:
> >
> > (define-type foo a b)
> > (define-type bar c d)
> >
> > (lambda (x)
> >   (let ((c (bar-c x) (d (bar-d x)))
> >     (let ((a (foo-a a) (b (foo-b b)) ...
>
> This is the kind of thing where macros get over-used
>
> (define (with-foo f body) (body (foo-a f) (foo-b f)))
>
> david
> --
> GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20090601/217b83cb/attachment.htm>


More information about the Gambit-list mailing list