curimit / SugarCpp

SugarCpp is a language which can compile to C++11.
135 stars 13 forks source link

Specific closuring in lambdas, as in C++11 #38

Open ozra opened 9 years ago

ozra commented 9 years ago

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