[gambit-list] Question/feature request regarding #!key parameters

Per Eckerdal per.eckerdal at gmail.com
Tue Sep 23 05:29:32 EDT 2008


Hi.

I am working on a hygiene system on top of Gambit. It is a syntactic
closures implementation and syntax-rules on top of that. There are
definitely some quirks left to fix, but it is slowly getting mature. I
have run into one problem though.

The code

(let ((a #t)) (let ((a #t)) a))

expands to something like

(let ((h1#a #t)) (let ((h2#a #t)) h2#a))

This is working fine. (It is so because the outer a must be reachable
from the inner let.)

However, this approach cannot be used for #!key parameters.

(define (fun #!key a) #f)

cannot expand into

(define (fun #!key h1#a) #f)

Because it would force the user of the function to call it like (fun
h1#a: name). It cannot expand into

(define (fun #!key a) #f)

either, because it breaks hygiene. This is what the system does right
now, but it would be nice to actually make correct. It works rather
well already, because #!key parameters are relatively rare, and
usually have rather unique names (that is, not builtin functions and
not nested with the same names).

Is there any way of working around this? One way of fixing this would
be to change Gambit to add support for syntax like (lambda (#!key
((outside-name . inside-name) default-value)) #f). In that case the
example above would expand into

(define (fun #!key ((a . h1#a) #f)) #f)

which would be hygienic. It would be better with something that didn't
needed a change in Gambit though.

Any ideas?

/Per



More information about the Gambit-list mailing list