Loop variable semantics
eliaslfox opened this issue · comments
Elias Lawson-Fox commented
I think this needs to be fixed. See this explanation in go.
Colin OKeefe commented
#986 (comment). Is this the same thing?
If so, I think we're already good. Here are some samples:
COALTON-USER> (coalton
(let ((v (vector:new)))
(for x in "hello"
(vector:push! (fn () x) v))
(map (fn (f) (f)) v)))
#(#\h #\e #\l #\l #\o)
COALTON-USER> (coalton
(let ((v (vector:new)))
(for x in "hello"
(vector:push! (fn () (traceobject "x" x)) v))
(for x in v (x))))
x: h
x: e
x: l
x: l
x: o
COMMON-LISP:NIL
The for
and while-let
forms recycle codegen from pattern matching, which expands matches out into cl:let
s. At least, that's my understanding.
If there's more to it than this, could you provide a code sample that elicits the bug?
Elias Lawson-Fox commented
It's looks like it's correct. Thanks for checking.