[gambit-list] syntax-case and procedures with keyword parameters

Marc Feeley feeley at iro.umontreal.ca
Sun Mar 4 13:20:12 EST 2012


On 2012-03-04, at 11:22 AM, Álvaro Castro-Castilla wrote:

> Marc,
> 
> I see.
> The only reason I miss syntax-rules is for some SRFIs and libs like
> Kanren, completely implemented as syntax-rules. Otherwise I'm happier
> with define-macro :)
> 
> Thanks for your reply

By the way, I should have mentionned in my previous message that when using the -:s switch, you still have access to ##lambda which does support DSSSL parameter lists.  The form ##lambda has the same syntax as lambda, but it is not under the control of the psyntax expander (which defines lambda as a macro).

So you can do this:

% gsi -:s
Gambit v4.6.4

> (define f (lambda (a b #!optional (c (+ a b)) #!rest d) (list a b c d)))
*** ERROR -- invalid parameter list in (lambda (a b #!optional (c (+ a b)) #!rest d) (list a b c d))
> (define f (##lambda (a b #!optional (c (+ a b)) #!rest d) (list a b c d)))
> (f 0 1 2 3 4)
(0 1 2 (3 4))
> (define f (##lambda (a b #!key (c (+ a b)) #!rest d) (list a b c d)))     
> (f 11 22) 
(11 22 33 ())
> (f 11 22 c: 99)
*** ERROR IN (console)@6.10 -- Unbound variable: c:
1> 
> (f 11 22 (string->keyword "c") 99) 
(11 22 99 ())
> (define c: (string->keyword "c"))
> (f 11 22 c: 99)                   
(11 22 99 ())

Marc




More information about the Gambit-list mailing list