Finally found some time to reply to this post.
First, thanks, Rick for "getting inspired" and beginning the work on an
implementation of ADDRESS WITH. Progress on the task will be immensely
improved with your participation.
Now to some more specific comments on your post. In order to support
the ANSI standard, we need to support STEM [REPLACE|APPEND] stemname and
STREAM [REPLACE|APPEND] streamname for the OUTPUT and ERROR
"connections" with the default of REPLACE if neither is specified, and
STEM stemname and STREAM streamname for the INPUT "connection". The
standard also states that any of the "connections" may be specified as
NORMAL, e.g. OUTPUT NORMAL, so that redirection may be reset. Just
wanted to be sure we have all the standard requirements spelled out
right at the beginning. Nothing worse than a "late" requirement being
"added"!
I really like the USING sub-keyword syntax for extending the standard!
I had been thinking more narrowly of either OBJECT or COLLECTION but
USING lets us also do a string, etc. This would be great for a case
where a command requires a simple confirmation or a password, etc. And,
I see no problem with the lack of Replace/Append support for
OUTPUT/ERROR objects since one could always code:
... USING (aList~~empty)
in order to ensure the aList object was "replaced". We need to
carefully document this, however, so that the behavior is not
"surprising" to a user that has come to expect REPLACE as the default in
another implementation.
Finally, thanks for the pointer to the location in the ooRexx source
where I should start looking to add my code. Hope to start that process
later today. And there WILL be questions as I go along!
Gil
On 3/29/2018 8:59 AM, Rick McGuire wrote:
OK, I got inspired by Gil's symposium presentation yesterday and have
started working on an implementation on this. I created a sandbox
version of 5.0.0 at url
https://svn.code.sf.net/p/oorexx/code-0/sandbox/rick/addresswith
This is very much a work in progress now that won't even build yet,
but I'm starting to put the pieces together.
The difficult part of this was always the redirection of the command
io streams and the handling reading and writing. Since Gil has figured
that out for Windows at least, we can start moving forward on this.
Here are my thoughts on implementing this.
1) The command will support STEM stemname., STREAM streamname, and
USING (expr).
The USING option will dynamically figure out how to use the evaluated
expression as a source or target. For INPUT, I'm looking at the following:
a) Value is a string. This will be a single line written to the
input stream.
b) Value is a stem object. Handled like the STEM option above.
c) Value is an InputStream object. The stream object is used for
input but no explicit open is
performed.
d) We attempt a makearray conversion on the object as is done with
do over and write the results as lines.
for OUTPUT,
a) Value is a stem, handle like the STEM object.
b) Value is an output stream. Handled like the STREAM option but
no explicit open is performed.
c) Value is an instance of OrderedCollection, append is used to to
add the items. Again, no APPEND/REPLACE support here.
These are not cast in concrete by any means, but that is my initial
stab at this.
2) Command handlers in ooRexx are done using a special interface to
implement different address environments. Currently, they are only
passed the name of the environment and the fully resolved command
expression. I'm working on creating a new type of interface for
command handlers that can participate in I/O redirection. This version
will be passed an additional C++ object that will act as an interface
between the handler and the interpreter. This object will have methods
to check which types of I/O are being redirected and also methods to
read from the input source and write to the output and error sources.
All the processing I described above is hidden from the command handler.
3) For Gil, the existing command handler for Windows system commands
can be found in the file
interpreter\platform\windows\SystemCommands.cpp. The code in there
that launches the shell looks a lot like the code you described in
your talk yesterday, so I think it would be fairly easy for you to add
the redirection hookups.
Rick
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel
--
Gil Barmwater
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel