You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One common mistake for Racket beginners (including me and some of my friends) is thinking that begin is used for grouping things. However, begin is in fact context-sensitive:
In the expression context, it can be used to group expressions.
In non-expression contexts, it splices its body out to enclosing form.
This causes a lot of confusion to me in the past. E.g.,
(let ()
(begin (define x 1)
(println (+ x 2)))
(println x))
;; 3
;; 1 <= why is x bound here?
(identity (begin (define x 1)
(println (+ x 2))))
;; define: not allowed in an expression context in: (define x 1) <= why doesn't it work
I propose that we have splicing-begin which is only for splicing, and change (begin body ...) to be semantically equivalent to (let () body ...).
This is more consistent: now all splicing forms are prefixed with splicing-.
(let () ...) idiom can be gone--which is good. For people who are not familiar with Scheme, this expression is very confusing: why do you use let if you are not going to introduce any binding?
If this will be confusing to existing Schemers, we could also change the name altogether. E.g., block and splicing-block, or seq and splicing-seq.
The text was updated successfully, but these errors were encountered:
One common mistake for Racket beginners (including me and some of my friends) is thinking that
begin
is used for grouping things. However,begin
is in fact context-sensitive:This causes a lot of confusion to me in the past. E.g.,
I propose that we have
splicing-begin
which is only for splicing, and change(begin body ...)
to be semantically equivalent to(let () body ...)
.splicing-
.(let () ...)
idiom can be gone--which is good. For people who are not familiar with Scheme, this expression is very confusing: why do you uselet
if you are not going to introduce any binding?If this will be confusing to existing Schemers, we could also change the name altogether. E.g.,
block
andsplicing-block
, orseq
andsplicing-seq
.The text was updated successfully, but these errors were encountered: