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

Remove unnecessary paren-shape calls #41

Closed harryfei closed 6 years ago

harryfei commented 6 years ago

I found that it does't work when using sweet-racket with hackett together like below.

#lang sweet-racket hackett

I digged into the code and found the issue is caused by those unnecessary paren-shape call.

After removing them, everything is fine.

AlexKnauth commented 6 years ago

I don't think this is the correct solution. We should be attaching paren-shape properties properly.

However, the correct property value for round parens is not #\(, but #false. We should fix that in the paren-shape function in sweet-exp-lib/sweet-exp/util.rkt.

Something like:

(define (paren-shape stx shape)
  (define val
    (cond [(char=? shape #\( ) #false] [else shape]))
  (syntax-property stx 'paren-shape val))

So that round parens correspond to a #false property value as they're supposed to.

AlexKnauth commented 6 years ago

Does the sweet-exp hackett program you were testing work now? This simple one works for me:

#lang sweet-exp hackett

defn f
  [0] 1
  [n] {n * f{n - 1}}

main
 print
  show f(4)
harryfei commented 6 years ago

@AlexKnauth Thanks. You are right. It works to use the latest new sweet-exp version.

So close this PR.