SugarCpp
SugarCpp copied to clipboard
Specific closuring in lambdas, as in C++11
It would be nice to be able to specifically say per variable, and generally wether the closure copies or references the context variables, as in C++11.
foo :size_t = 42
groink := true
lamb := [=, &foo]() -> int
groink = false
foo = 47
return 13
blargh := lamb()
assert(groink == true)
assert(foo == 47)
assert(blargh == 13)
Though, perhaps it could syntactically be incorporated in the arg list, clarifying that it's data utilized by the function - this though in turn obscures the functions actual signature instead:
lamb := (=, &foo, an-actual-argument :int) -> int
groink = false
foo = 47
return an-actual-argumet + 13