grol-io / grol

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

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

Closed ldemailly closed 2 months ago

ldemailly commented 2 months 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