takikawa / sweet-racket

A port of sweet expressions to Racket
http://pkg-build.racket-lang.org/doc/sweet/index.html
Other
47 stars 10 forks source link

treat #:keywords specially #10

Closed AlexKnauth closed 9 years ago

AlexKnauth commented 9 years ago

closes https://github.com/takikawa/sweet-racket/issues/4

Is it a good idea to start special-case-ing like this though?

AlexKnauth commented 9 years ago

What do you think about this?

takikawa commented 9 years ago

I'm hesitant to add a special case so I'm not sure yet. I wonder if there is a good pattern to deal with keywords like this?

AlexKnauth commented 9 years ago

Ok. I could just put all keyword arguments on a separate line, but that would take up a lot of unnecessary space. Or I could make a language with a redefined #%app that would treat (#%app foo (#:kw kw-arg)) like (#%app foo #:kw kw-arg), and with redefined versions of syntax/parse forms that would do similar things, etc, but since #:keywords normally shouldn't be wrapped in parens, it might make sense to make this a special case. I agree that special cases are not a particularly good thing, but it might be worth it.

takikawa commented 9 years ago

Ok, I'm fine with merging it since there doesn't seem to be a better way to handle keywords.

The tests/rest-arg.rkt test seems to fail for me though. Does it work for you?

AlexKnauth commented 9 years ago

Oh. It fails for me too, but both on this and on master. So I'm guessing I probably broke it in https://github.com/takikawa/sweet-racket/commit/3dd16f5009d318aee07551781431c78aa42670c7.

AlexKnauth commented 9 years ago
check-equal?(thrush(+ add1)(3) 4)

is reading to

(check-equal? (thrush (+ add1) 3) 4)

When it should be reading to

(check-equal? ((thrush + add1) 3) 4)

Right?