These are chat archives for ChaiScript/ChaiScript

15th
Apr 2015
Victor Lopez
@VictorJL
Apr 15 2015 02:41
Victor Lopez
@VictorJL
Apr 15 2015 02:59
Also, how can I iterate a map in ChaiScript? taking as reference C++ iterations.
for(auto& mapping : map){
                                                       mapping.first;
                                                       mapping.second;
                                                 }

I think that with the

for(auto& it : iterable)

Iteration.
Everything should be excellent.

Victor Lopez
@VictorJL
Apr 15 2015 04:38
Lambda assignment issue. Look forward the object constructor. When assigning to this.on_trigger the on_trigger function does not triggers when calling this.on_trigger()
https://gist.github.com/VictorJL/6f7ae552d61d3e5a89ae
Victor Lopez
@VictorJL
Apr 15 2015 04:43
Those are all the issues I did find. The latter being a bit more critical.
I tried to do this.on_trigger = on_trigger but the function does not trigger, it is not being called at all.
Not even when I do
this.on_trigger = fun(){ print("trigger") } 
this.on_trigger()
Jason Turner
@lefticus
Apr 15 2015 13:56
@VictorJL I believe all of these are essentially the same issue. this.on_trigger() is returning the function that is assigned to the on_trigger property, not calling that function. so something like: this.on_trigger()() might work, or var t = this.on_trigger(); t(). It's close to the top of my to-do list to figure that out, but it might get difficult to sort out the difference between "call the function that returns the property" and "call the function that is contained in the property". Thinking about it this way: this.on_trigger is exactly the same as on_trigger(this). so you could also do: on_trigger(this)() until I get this figured out.
also, sorry I'm a bit behind on bugs, I have consulting work I need to catch up on, so I can get paid.
Jason Turner
@lefticus
Apr 15 2015 14:04
This is a to-do item: ChaiScript/ChaiScript#145 for for each loops like you are asking about, you can use for_each(map, fun(i) { i.first; i.second; }) like the c++ for_each would work