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

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Sun Nov 16 15:15:46 EST 2008

Agree. I wish for (define-struct foo (yada yada2)) the struct type 
identifier
were called <foo> instead of foo. However it is a pretty invasive change.

/Jens Axel
 

Dave Herman wrote:
> +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
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.