Bonjour Jean-Louis,

thank you very much for all your answers, and also (especailly!) for the 
pointers to further
information about CoRoutines!

Maybe others have also questions to the different concepts you have 
implemented, hence I would keep
myself a little bit quiet to not dominate these questions, discussions.

---

There is one exception regarding the closures:


On 29.12.2011 10:32, Jean-Louis Faucher wrote:
>
>     It looks as if one is able to define any Rexx code as a literal by using 
> curly brackets around
>     them.
>     These literals can then be run/executed later.
>
>
> yes, but not all blocks are closures.
> Only a block starting with ::cl[osure] will let create a closure.
What is a "closure" and what is your syntax for it?

E.g. what does "{}~variables" do and why is "[::closure}~variables" different 
to the former?

> This block has an associated directory of variables. No need to create a 
> snapshot of the variables
> for the other kinds blocks.
>
> v=1 ; {}~variables=
> [The NIL object id#_537657582]
>
> v=1 ; {::cl}~variables=
> type: The Directory class: (3 items)
>
>     # 1: index=[RC]   -> item=[0]
>     # 2: index=[SIGL] -> item=[364]
>     # 3: index=[V]    -> item=[1]
So "{...}~variables" returns a directory of variables defined in the block "{}" 
or does it return a
directory of variables made available to the block "{...}" as the second 
example with "::closure"
indicates?

Again, what is the difference between "{...}" and "{::closure ...}"?

>  
>
>     Do you have a brief problem, example where one can see what is needed for 
> a "bare-bone"
>     closure and
>     how it helps solve some problems in an easier way than with what is 
> currently available in ooRexx?
>
>     Or maybe reformulated: what is special about the closures, that makes it 
> easier for the programmer
>     to take advantage of them, rather than using what ooRexx has already? 
> What do closures allow for,
>     that is not really possible now?
>
>  
> Well, it's a matter of code organization. There is nothing you can't do 
> without closures. It's
> just you can have more compact code, assuming you like this kind of code :-)
>
> Ex1 :
> In this example, you create functions on-the-fly from a common block.
>
> range = { use arg min, max ; return { ::closure expose min max ; use arg num 
> ; return min <= num &
> num <= max }}
Hmm, why would you have nested blocks? Why is the inner block led in by 
"::closure" and why is that
necessary in this example? What does "expose" in a closure do? What does "use 
arg num" in the inner
block refer to and why?

> from5to8 = range~(5, 8)
So is "from5to8" an object representing the code above and by sending that 
doer/executable/runnable
object a message, it gets executed supplying the arguments of the message to 
that code block?

> from20to30 = range~(20, 30)
Again, is "from20to30" a block of executable code, where "min" and "max" are 
set and which later can
be used to execute code?

And if so, why is the argument to the message not supplied as an argument to 
the executable code
(outer block), but obviously as an argument to the inner block defined to be a 
closure?

> say from5to8~(6) -- 1
> say from5to8~(9) -- 0      
> say from20to30~(6) -- 0
> say from20to30~(25) -- 1
>
>
> Ex2 :
> In this example, a closure is needed to have access to the 'translation' 
> variable. You can't pass
> it by parameter, because it's not you who calls the block.
Who does call/execute the block then?

> translation = .Directory~new
> translation["quick"] = "slow"
> translation["lazy"] = "nervous"
> translation["brown"] = "yellow"
> translation["dog"] = "cat"
> translation~setMethod("UNKNOWN", "return arg(1)")
> say "The quick brown fox jumps over the lazy dog"~mapW{::cl expose 
> translation ; translation[arg(1)]}
Which argument does "arg(1)" refer to in the above statement?
> ::requires "extension/extensions.cls"
What does the method "mapW" do? What are the arguments to it? What would be the 
input and what would
be the produced output?

> Ex3 :
> In this example, the 'partial' method returns a closure which remember the 
> parameter 10.
Where is the method "partial" defined and what does it do? What executable code 
object does it return?

> add10 = "+"~partial(10)
What does "add10" represent in this case?

> say add10~(1) -- 11
Why would one get "11" as a result in this case?

---

Sorry for these "stupid" questions! Looking at the example code and your brief 
comments, I can guess
the one or other mechanics being made available. However, I am not really sure 
whether my
thoughts/guesses are right at the head of the nail, hence these questions!

Again, to not dominate questions ad your experimental ooRexx interpreter (I am 
sure others are
interested as well and have questions), I will try to keep a little bit 
"quiet", such that others
have a chance to ask questions as well!

Regards,

---rony


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to