Re: Quick vote about portable keyword argument syntax Marc Nieper-WiÃkirchen 02 Nov 2019 16:21 UTC
Am Fr., 1. Nov. 2019 um 20:44 Uhr schrieb Lassi Kortela <firstname.lastname@example.org>: > > 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)) > > 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. How do you want (let ((:e 3)) (keyword-call foo 1 2 :e 4)) being handled? While Option 2 looks much better than Option 1, it doesn't seem to work well when the underlying Scheme does not have a separate keyword type (and keyword syntax). So what about the following Option 3? (keyword-call foo 1 2 : e 5) In Schemes with a keyword reader syntax, it can be expressed as (keyword-call foo 1 2 #:e 5) Option 3 is also implementable using syntax-rules alone.