Re: Alternative formulations of keywords
Marc Feeley 12 Apr 2006 14:57 UTC
On 12-Apr-06, at 10:28 AM, John Cowan wrote:
> Marc Feeley scripsit:
>
>> 1) find an alternative mechanism that avoids the need for keyword
>> objects (i.e. you view foo: as a symbol and want to keep it that way)
>
> Yes, though I am obviously okay with allowing such symbols to be
> self-evaluating.
>
>> 2) find an alternative mechanism that avoids the proposed parameter
>> list syntax (with #!key, etc)
>
> No, although I don't consider this essential, since my approaches
> all involve a standardized run-time representation.
>
>> 3) find an alternative implementation of the SRFI (i.e. you are OK
>> with the specification)
>
> No.
OK, then please explain why in your proposal #2 the compiler needs to
transform:
(foo 'bar foo: 32 bar: 54)
into:
(foo 'bar (list (cons foo: 32) (cons bar: 54)))
For your purposes, wouldn't it be sufficient to use a rest parameter
in the definition of foo and parse that in foo?
(define (foo a . rest)
(let ((optionals (alistify rest)))
...))
Note that this is what the reference implementation of SRFI 89 does.
Then there is no need for the compiler to treat keywords specially
(except they need to be self evaluating).
Also, consider the function definition:
(define (f a b #!key (y 11) (z 22)) ...)
and the call:
(f x: 33 z: 44 y: 55)
In this case, I want parameter a to be bound to x: and b to be bound
to 33. I don't see how this would work with your proposals.
In summary, I fail to understand which problem you are trying to
solve with proposal #2. I also don't understand proposal #3.
Marc