Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2012-01-06 Thread Uli Zinngrebe
On Thursday 05 Jan 2012 01:21:48 Jean-Louis Faucher wrote:

Hi Jean-Louis,

 
  There is a segmentation fault after re-tokenisation, but it doesn't kill
  rxapi.
 
 I'm curious to know : how often do you have  crashes when using your build
 ? I re-tested today under Puppy, running functional-test.rex. When the
 modified rxapi is started as a daemon, I have a crash on one of the two
 executions.
 
same here, segmentation fault every other execution.
my original interpretation is wrong.

 
 A preliminary remark : given the experimental aspect of my sandbox, I had
 in mind a no install delivery for preview, rather than a real install.
 So I would be interested to know if you have specific reasons to make a rpm
 (I'm just curious :-)

1) I'm an amateur and don't know better.
Not knowing where to start I just did make rpm and follwed up on the errors.

2) rpm protects me from myself, i.e. ruining an installation by manual editing 
as root. rpm manages dependencies, and it is easy to switch rexx versions:
rpm -e old.rpm  rpm -i new.rpm 
 
 I have a question about this comment in your script :
 *Patches install also trunk/samples/native.api; they do not install new
 header files.*
 Normally, I'm in sync with main/trunk, so it means that samples/native.api
 are not part of the official delivery, and should be ? I did not take time
 to verify... The files are listed below.

samples/native.api are not part of the official linux delivery.
I thought they were cross-platform and should be included, but see 
http://sourceforge.net/support/tracker.php?aid=3469948

I just gave it a try and it doesn't compile straight away.

uli@ulmo:~/oorexx/sandbox/jlf/trunk/samples/native.api/call.example cp 
Makefile.linux Makefile
uli@ulmo:~/oorexx/sandbox/jlf/trunk/samples/native.api/call.example make
gcc -c -fPIC -o runRexxProgram.o runRexxProgram.cpp
runRexxProgram.cpp: In function ‘int main(int, char**)’:
runRexxProgram.cpp:100:44: error: ‘strcmp’ was not declared in this scope
make: *** [runRexxProgram.o] Error 1

 And which are these new header files not installed ?
 $(m17nHeaders) 
 $(m17nCharsetHeaders) 
 $(m17nEncodingHeaders) 

The makefile contains a few header files which are installed (like 
rexxplatformdefs.h) but most are not. Not knowing in which group to place the 
new headers, I left them with the majority (uninstalled) and put a warning.

 
 I applied the patches and made a make install (I don't have rpmbuild).
 Then, I made a diff between the previous tree file, and the new one. The
 new files are listed below, and that brings some questions :-)
 
  ooRexx-jlf/bin/concurrency
  ooRexx-jlf/bin/concurrency/activity.cls
...

 All the files above are more library files than binary files. I understand
 that putting them in bin let find them automatically, because the PATH
 includes the bin directory. But see below, there are also some library
 files that you put under share/ooRexx.
 
  ooRexx-jlf/share/ooRexx/native.api
  ooRexx-jlf/share/ooRexx/native.api/call.example
...

I don't have a strong opinion and to start with I wasn't sure whether it is 
just an example or for general use. A symlink to /usr/bin could be set.
 
 Assuming we start thinking about a standard library for ooRexx, what should
 be the file organization ? I did not take time to study Python and Ruby
 libraries, there are probably some common practices.

rpm -ql ooRexx 
to see how *.rexx *.cls and executables ae installed: the structure is flat, 
there is no notion of packages.
this has the advantage that path elements are not hardcoded in the sources, 
so classes can be relocated or regrouped into new packeages without breaking 
classes. 
While path elements are hardcoded in the scripts and classes, a flat 
installation is not possible.


 See my previous question about native api files.
 
  ooRexx-jlf/share/ooRexx/pipeline
  ooRexx-jlf/share/ooRexx/pipeline/pipe.rex
 
 Files above are library files. share/ooRexx seems the good place to
 deliver them. I assume this directory is added to PATH by the installer ?

I think it is safer to provide *.cls files, because ::requires is checked when 
the script starts and independent of program flow.
I haven't considered whether they are meant for interactive command line.

I have to give the subject more thought.


Cheers, Uli

 
  ooRexx-jlf/share/ooRexx/_samples
  ooRexx-jlf/share/ooRexx/_samples/doers-benchmark.rex
  ooRexx-jlf/share/ooRexx/_samples/doers-info.rex
  ooRexx-jlf/share/ooRexx/_samples/doers-samples.rex
  ooRexx-jlf/share/ooRexx/_samples/doers-stress.rex
  ooRexx-jlf/share/ooRexx/_samples/functional-test.rex
  ooRexx-jlf/share/ooRexx/_samples/pipe_extension_test.rex
 
 Files above are samples files. No remark, except maybe that we have some
 sample files directly under share/ooRexx. Maybe we need a proper
 distinction between library files and samples files ?
 
  ooRexx-jlf/share/ooRexx/trace
  ooRexx-jlf/share/ooRexx/trace/tracer.rex
  

Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2012-01-03 Thread Uli Zinngrebe
On Saturday 31 Dec 2011 12:46:11 Jean-Louis Faucher wrote:

Hi Jean-Louis,

thank you very much for the warning and the fix.
But an occasional crash doesn't sound too bad, so I left rxapi as daemon.
There is a segmentation fault after re-tokenisation, but it doesn't kill 
rxapi.

I had some basic problems configuring the installation, so I put the changes 
as patch under http://sourceforge.net/support/tracker.php?aid=3469313.


Cheers, Uli

 Hi Uli,
 
 do you mind if I make me linux binaries from your sandbox, using the
 
  packages
  from dropbox ?
 
 No problem.
 
 Something to know : the rxapi server has been modified to send trace
 messages to stderr.
 If you do a release-build from the sandbox, then you will have intermittent
 crashes, because the server starts as a daemon (no stderr). I will fix that
 in the sandbox, by not writing to stderr if started as a daemon.
 In the meantime, you can edit this file :
 sandbox/jlf/trunk/rexxapi/server/platform/unix/linux/APIService.cpp
 and put in comment : #define RUN_AS_DAEMON
 Then, you have just to start rxapi by hand in a terminal, and use another
 terminal to run rexx.
 
 Just in case, I made a build for Puppy Linux, available through dropbox.
 I don't know if that will work for other Linux distributions.
 Puppy Linux is a minimal distribution. There is only one user : root
 So the files owner in the taz is root...
 
 Jean-Louis

--
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
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-31 Thread Jean-Louis Faucher
Hi Uli,

do you mind if I make me linux binaries from your sandbox, using the
 packages
 from dropbox ?


No problem.

Something to know : the rxapi server has been modified to send trace
messages to stderr.
If you do a release-build from the sandbox, then you will have intermittent
crashes, because the server starts as a daemon (no stderr). I will fix that
in the sandbox, by not writing to stderr if started as a daemon.
In the meantime, you can edit this file :
sandbox/jlf/trunk/rexxapi/server/platform/unix/linux/APIService.cpp
and put in comment : #define RUN_AS_DAEMON
Then, you have just to start rxapi by hand in a terminal, and use another
terminal to run rexx.

Just in case, I made a build for Puppy Linux, available through dropbox.
I don't know if that will work for other Linux distributions.
Puppy Linux is a minimal distribution. There is only one user : root
So the files owner in the taz is root...

Jean-Louis
--
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
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-30 Thread Rony G. Flatscher
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

Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-30 Thread Jean-Louis Faucher
Guten tag Rony,

 What is a closure and what is your syntax for it?


A closure is a block (class RexxBlock) who remembers the value of the
variables defined in its outer environment.
The syntax is {::closure ...}, where ::closure is a tag which can be
abbreviated ::cl.
For a list of all tags, see
http://oorexx.svn.sourceforge.net/viewvc/oorexx/sandbox/jlf/trunk/interpreter/RexxClasses/Parser.orx?view=log


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


{} is an empty source literal.  The default tag is ::routine.
{::closure} is a source literal tagged ::closure. The tag makes the
difference.
Since doing a copy of .context~variables has a cost, there is no reason to
do it when not needed.
Not sure I will keep the method ~variables on RexxBlock. Currently, I need
it to initialize the closure instance, but there is probably no reason for
an end-user to have access to this directory.

  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?


The first block can be rewritten as a routine, no more nested blocks, but
the code is less compact, and the order less natural (you discover the
definition of the routine after the place from where it's called). The
inner block is an object (RexxBlock) returned by the routine.

from5to8 = range(5, 8) -- function call, here no tilde
say from5to8~(6) -- from5to8 is a RexxBlock to which the message ~() is
sent

::routine range
use arg min, max
return { ::closure expose min max ; use arg num ; return min = num  num
= max }

Why is the inner block led in by ::closure and why is that necessary in
 this example?


The tag ::closure is needed to capture the values of min and max.
When the RexxBlock is returned to the caller, the values of min and max are
still available, despite the fact the context of the routine 'range' no
longer exists.


 What does expose in a closure do?


A closure is an instance of .Closure which has only one do method, whose
source is given by the source literal (after removing the tag). The
directory of variables on the RexxBlock is used to create instance
variables inside the closure instance. The expose is used to make visible
the needed variables.
This is a naive implementation, there is room for optimization.


 What does use arg num in the inner block refer to and why?


Since the object returned by range is a RexxBlock, you can execute this
block and pass arguments. Here, the block expects a number argument.

  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?


yes, exactly.
from5to8 is a RexxBlock to which the message ~() is sent with the
argument 6. This message is forwarded as do message to the doer
associated to the RexxBlock. Here, the doer is a closure. The do method
receives the argument 6 and has access to the exposed min and max
variables, which were captured when the range routine was called.

  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?


yes.
Each time the range routine is called, a new instance of RexxBlock is
returned, which holds the .context~variables of the range routine. Since
the parameters min and max belongs to this directory, they are captured.

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?


See comments above.


   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?


The block is called by the mapW method.
You call the mapW method, but you have no way to pass the translation
directory to it, because mapW accepts only one parameter : the action to
apply on each word of the string.
The action must be a doer factory, i.e. must understand ~doer. The action
can be a routine or a method or a message or a coactivity or a closure or a
block. Among all those objects, only a block is really a factory. The other
objects return themselves when sending the message ~doer, because they are
already executable.


   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?


arg(1) is the current word being processed.

 What does the method mapW do? What are the arguments to it? What would
 be the 

Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-30 Thread Mark Miesfeld
On Fri, Dec 30, 2011 at 3:24 AM, Rony G. Flatscher 
rony.flatsc...@wu-wien.ac.at wrote:


 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.



Rony - go ahead and ask your questions.  I'm following this, but don't have
the time to delve into it to deeply.  If you ask a question then the
conversation is in my archieve and I can come back to it later.

--
Mark Miesfeld
--
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
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-30 Thread Uli Zinngrebe
On Friday 30 Dec 2011 17:24:52 Jean-Louis Faucher wrote:
 [ ... ]

Jean-Louis,

do you mind if I make me linux binaries from your sandbox, using the packages 
from dropbox ?

Cheers, Uli

--
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
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


Re: [Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-29 Thread Jean-Louis Faucher
 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. 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]



 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 }}
from5to8 = range~(5, 8)
from20to30 = range~(20, 30)
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.

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)]}
::requires extension/extensions.cls


Ex3 :
In this example, the 'partial' method returns a closure which remember the
parameter 10.

add10 = +~partial(10)
say add10~(1) -- 11
--
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
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel


[Oorexx-devel] Question ad closures... (Re: Ad experimental ooRexx ... (Re: Question ad rev. 7391 (sandbox/jlf)

2011-12-28 Thread Rony G. Flatscher
Bonjour Jean-Louis:

just starting to look into your closure implementation.

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.

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?

TIA,

---rony


--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
___
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel