[plt-scheme] Using the struct type identifier as a macro [PATCH]

From: Dave Herman (dherman at ccs.neu.edu)
Date: Sun Nov 16 15:03:53 EST 2008

+1

On Nov 12, 2008, at 11:45 AM, Dimitris Vyzovitis wrote:

> The struct type identifier contains the expansion time information,
> but is otherwise sitting unused as a macro. This is a waste of a
> perfectly good identifier; the macro can be used as a
> constructor. Similarly, the match syntax can be adapted for symmetry,
> avoiding the current (overly verbose) struct form.
>
> The attached patch (against svn 12407) does this: The
> (checked-)struct-info info macro acts as a constructor when the
> constructor identifier is available.  Similarly, match is adjusted to
> symmetrically deconstruct structs by using the type name directly.
>
> Example:
> (define-struct test (x y))
> (test 1 2) => #<test>
> (match (test 1 2) ((test x y) (list x y))) => '(1 2)
>
>
> -- vyzo<struct.patch>_________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.