racket / scribble

Other
197 stars 91 forks source link

Order of evaluation of parameterize is wrong #236

Closed sorawee closed 4 years ago

sorawee commented 4 years ago
(define p1 (make-parameter 1 (λ (x) (displayln "p1") x)))
(define p2 (make-parameter 2 (λ (x) (displayln "p2") x)))

(parameterize ([(begin (displayln "b1") p1) (begin (displayln "a1") 4)]
               [(begin (displayln "b2") p2) (begin (displayln "a2") 5)])
  3)

results in:

b1
a1
b2
a2
p1
p2
3

According to the docs:

All of the parameter-exprs are evaluated first (and checked with parameter?), then all value-exprs are evaluated, and then the parameters are bound in the continuation to preserved thread cells that contain the values of the value-exprs.

So b1 and b2 should be the first two lines. The docs is not clear how a* and p* should interleave, so it would be nice to clarify those as well.

Lastly, the docs has a typo: body-expr should instead be body. There are two occurrences of body-expr.

sorawee commented 4 years ago

I didn't mean to create this in racket/scribble, sorry! Closing.