Re: Quick vote about portable keyword argument syntax
Per Bothner 01 Nov 2019 20:57 UTC
On 11/1/19 12:44 PM, Lassi Kortela wrote:
> Can we have a quick vote about who prefers the current option 1:
>
> (keyword-lambda (a b (c d e)) <lambda body ...>)
>
> (keyword-call foo 1 2 (e 5 c 3 d 4))
I don't like this syntax - it awkwardly separates the keyword
arguments from positional arguments. Better would be:
(keyword-call foo 1 2 (e 5) (c 3) (d 4))
I realize this may be more difficult, and might have some
problems with ambiguity.
> And who would prefer option 2 where all of these are supported:
>
> (keyword-lambda (a b :key c d e) <lambda body ...>)
>
> (keyword-call foo 1 2 e: 5 c: 3 d: 4) ; In all Schemes
> (keyword-call foo 1 2 :e 5 :c 3 :d 4) ; In all Schemes
> (keyword-call foo 1 2 #:e 5 #:c 3 #:d 4) ; In Schemes that have #:
>
> Option 1 can be implemented with syntax-rules and tail patterns.
>
> Option 2 needs syntax-case, explicit-renaming, or define-macro. It can be implemented equally well in Schemes that have native read syntax for keywords, and Schemes that don't. The trick is to treat a symbol starting or ending with a colon as a keyword.
Partly because this is closer to Kawa, it would be my preference.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/