grol-io / grol

Go REPL Open Language
https://grol.io
Apache License 2.0
13 stars 1 forks source link

Allow mutations in upper scope, add back `:=` for forcing local scope variable creation #207

Closed ldemailly closed 1 week ago

ldemailly commented 1 week ago

Until now every capture of state was a copy, it was impossible to modify upper state without collaboration from the caller in term of assigning a result

We introduce capture by reference instead of by value by default now. And a:=a to make a local copy (or only use the function arguments which are always local)

a = 2
()=>{a=3}()
a // now 3