Rony G. Flatscher wrote:
> Hi Jean-Louis,
> 
> first: thank you very much for your instructive post!
> 
> 

<snip>

>> Instructions that can be called only from methods :
>>
>> expose : I still don't understand why it's not possible to expose 
>> variables from a ::routine...
>> If we do a relation with
>> - anonymous inline functions (often called lambda or block),
>> - outer environment (the variables used by the lambda, which are not 
>> parameters),
>> - and closure (which is the outer environment which remains associated 
>> to the lambda, even when the lambda is called outside the definer's 
>> scope),
>> then the exposed variables would be the variables to retain in the 
>> closure.
>> Most of the languages don't require to declare the variables to 
>> capture, but C++ lets /optionally/ declare them, and that remind me 
>> the functionality of our expose :
>> ----- c++
>> std::vector<int> some_list;
>> int total = 0;
>> std::for_each(some_list.begin(), some_list.end(), [&total](int x) { 
>> total += x; });
>> ----- oorexx (with extensions)
>> some_list = .array~of..
>> total = 0
>> some_list~each([expose total; total += arg(1)])
>> -----
>> C++ lets capture a variable by value or by reference. In ooRexx, 
>> expose is always by reference, right ? Currently, only internal 
>> procedures allow to expose variables, but internal procedures can't be 
>> manipulated like routines...
>> In the example above, there is a need of closure, because the lambda 
>> is called in the context of the 'each' method, which is not the 
>> context of the definer (i.e. 'each' does not - and could not - expose 
>> the 'total' variable).
>>
>>
>> forward : nothing to say
>>
>>
>> guard : in relation with the object variables dictionary (ovd). I 
>> don't know if the routines have a similar concept like caller 
>> variables dictionary (cvd ?). And I don't know if that would make 
>> sense to manage synchronisation on this cvd. Probably yes, 
>> synchronisation would be necessary if we allow
>> - reply and expose in ::routine
>> - expose and closure (even if no reply in ::routine, because thanks to 
>> the closure, a routine can be passed as argument to methods which 
>> reply, and then call the routine which will access to the exposed 
>> variable of the closure).
> 
> Wow, that sounds very interesting! It would be really great (and 
> functionality wise very helpful!) to add lambda/block and closures to 
> ooRexx!
> 
> ---rony

I seem to remember that Simon Nash stated during his presentation at the
2009 Symposium that a conscious decision was made to NOT implement
closures in ORYX but I don't recall that he gave a reason nor that
anyone asked.  Perhaps Rick might recall why.  I know I'd be interested
in the reasoning.

-- 
Gil Barmwater

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to