Comparing current and potential future syntaxes
Lassi Kortela 22 Feb 2020 01:25 UTC
Exploring a bit more:
- SRFI 177 (compatible, simple and dumb, hacks are ok)
(define/kw (foo a b c :key d e f) ...)
(call/kw foo 1 2 3 :d 4 :e 5 :f 6)
- All of #:key and :key and key: are recognized and equivalent.
- All of #:e and :e and e: are recognized and equivalent.
- All identifiers and keyword objects refer to global keywords.
- Future hygienic keywords SRFI
(define/kw (foo a b c (d e #:f)) ...)
(call/kw foo 1 2 3 (d 4 e 5 #:f 6))
The parentheses show which args are in keyword position.
Keyword objects stand for global non-hygienic keywords,
whereas ordinary identifiers are hygienic keywords.
Instead of the parenthesis, could also use a standalone one-character :
identifier. But I think it's hard to read when used together with the #:
global keyword object syntax:
(call/kw foo 1 2 3 : #:d 4 #:e 5 #:f 6)
(call/kw foo 1 2 3 : #:d 4 : #:e 5 : #:f 6)
Hygienic keywords would make it only slightly easier to read:
(call/kw foo 1 2 3 : d 4 : e 5 : f 6)
At this point I would already find the original syntax easier:
(call/kw foo 1 2 3 (#:d 4 #:e 5 #:f 6))
(call/kw foo 1 2 3 (d 4 e 5 f 6))
I'd like to re-iterate that much more important than the particular
syntaxes we pick, is that any syntax can call keyword procedures defined
with any other syntax. As long as we honor that requirement, we cannot
mess up too badly. But if we don't, we'll end up with a situation like
incompatible module systems that's an impediment to portable Scheme.