[plt-scheme] Re (modified): macros that expand into LISTS OF top-level definitions with computed names
Replace the build-list code with the name-generating stuff that we
discussed earlier (i.e., create a list of names such as exec.push and
float.push etc) and replace (define-values (type ...) (values
index ...)) with (define-values (index ...) (values type ...)) and
your first concern is covered. (If push comes to shove, just use map/
car/cdr and friends to write the code -- just like in CL, but using
syntax objects. Then you're done, too.)
I don't understand the second one.
On Aug 14, 2009, at 3:10 PM, Lee Spector wrote:
>
> That does help insofar as it tells me that the key to iteration in
> macro expansion (to use the CL terminology) seems to be the
> ellipsis, which is new to me and seems pretty interesting. I'll
> still have to figure out how to combine this with the symbol-
> merging code and figure out how to do this with the list of types
> defined separately... all of which is resisting my initial
> attempts, I guess because I still haven't wrapped my head around
> PLT syntax object concepts.
>
> Thanks again,
>
> -Lee
>
> On Aug 14, 2009, at 11:54 AM, Matthias Felleisen wrote:
>
>>
>> On second thought, this example is closer to what you need:
>>
>> (define-syntax (def-all stx)
>> (syntax-case stx ()
>> [(_ type ...)
>> (with-syntax ([(index ...) (build-list (length (syntax->list
>> (syntax (type ...)))) add1)])
>> #`(begin (define-values (type ...) (values index ...))
>> (register-instruction 'type)
>> ...))]))
>>
>> (define (register-instruction x) x)
>>
>> (def-all exec float integer)
>>
>> exec float integer
>>
>>
>>
>> On Aug 14, 2009, at 11:44 AM, Matthias Felleisen wrote:
>>
>>>
>>> Will this help you along?
>>>
>>> #lang scheme
>>>
>>> (define-syntax (def-all stx)
>>> (syntax-case stx ()
>>> [(_ type ...)
>>> #`(begin (begin (define type 1)
>>> (register-instruction 'type))
>>> ...)]))
>>>
>>> (define (register-instruction x) x)
>>>
>>> (def-all exec float integer)
>>>
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> --
> Lee Spector, Professor of Computer Science
> School of Cognitive Science, Hampshire College
> 893 West Street, Amherst, MA 01002-3359
> lspector at hampshire.edu, http://hampshire.edu/lspector/
> Phone: 413-559-5352, Fax: 413-559-5438
>
> Check out Genetic Programming and Evolvable Machines:
> http://www.springer.com/10710 - http://gpemjournal.blogspot.com/
>