John Cowan tries to keep it simple
John Cowan
(03 Nov 2019 05:46 UTC)
|
Re: John Cowan tries to keep it simple Lassi Kortela (03 Nov 2019 11:58 UTC)
|
Re: John Cowan tries to keep it simple
Lassi Kortela
(03 Nov 2019 12:13 UTC)
|
Re: John Cowan tries to keep it simple Lassi Kortela 03 Nov 2019 11:58 UTC
> I'm starting to get lost in all these options. Here's how I think things > should look: > > (call/kw name expr ... marker :kw expr :kw expr ...) > > I don't care exactly what the marker is. But this way it looks exactly > like a normal function call except for the leading call/kw and the marker. > If a user thinks call/kw is too verbose, it's easy to write a syntax-rules > macro that lets you use a shorter (or even longer) name. > > I also don't care if the keyword identifiers have colons in them or not. > And by the same token: > > (lambda/kw (identifier ... marker identifier ...) . body) > > Again, it looks as much like plain lambda as it possibly could. I like this, and it's basically what all the implementation-native syntax already use. > Thirdly, I would also like this: > > (define/kw (procname identifier ... marker identifier ...) . body) I've had `define` in mind from the beginning, but have kept it out on grounds of simplicity. I still don't know what to do about it. SRFI 89 has `define*`. My worry is there may be Scheme implementations where `define` is magic so that `(define x (lambda (y z) ...))` is not an adequate substitute for `(define (x y z) ...)`. Care has to be taken so that 177's `define/kw` would expand into a `(define (x ...) ...)` form instead of `(define x <whatever>)`. Then we can probably ensure that any subtleties of the implementation's `define` are preserved, and it would be fine. Editor indentation is also worth keeping in mind. Luckily, Emacs already indents both (define x (lambda/kw ...)) and (define/kw ...) correctly. > What do you think of this design? It sacrifices the possibility of a > syntax-rules implementation, and it doesn't allow for these mythical > hygienic keywords, but I don't care about either of these points. Because > this is simple to use. I have the same priorities as you. Based on the above meditations, a `define/kw` is probably fine. But something about it makes me intuitively cautious; I can't tell what it is. Probably that too many `define` forms in the language can cause confusion. It's clear that `lambda/whatever` defines some kind of procedure, but does `define/whatever` define a procedure or some other kind of object? Of course one can look all that up in the documentation, but I always try to go for designs that remove the need for subconscious worries and diligence. From a usability standpoint, I love `lambda/kw` since it fits like a glove: everyone already knows what lambda is. Maybe we should try writing some sample code with `define/kw` to see if we get used to it. > Question: You can use apply to call a kw-procedure with no keywords. Does > that also mean you can call it directly without call/kw? Yes, absolutely. That's one of the most important properties of the current design to me. One less thing for users (and people adding keywords to previously non-keyword procedures) to worry about!