Hi Rony,

Missatge de Rony G. Flatscher <rony.flatsc...@wu.ac.at> del dia dg., 9 de
març 2025 a les 11:40:

> 1) ad stem arrays
> ==============
>
> Stem arrays have been conceived and used since the inception of Rexx.
>
> The pattern is simple: the tail is an integer number from 1 on, the tail
> with the value 0 keeps the current number of total stem array elements.
> E.g.:
>
> a.1="one"
> a.2="two"
> a.0=2 
> say "there are" a.0 "items"
>
> Turning such a stem array into an ooRexx array should yield an array that
> omits the element with the tail 0 and uses the tail's number as index in
> the ooRexx array. E.g. turning the above stem array into an ooRexx array:
>
> a[1]="one"
> a[2]="two"
> say "there are" a~itmes "items"
>
> 1a) In order to create an ooRexx array from a stem array the following
> method should be added to the stem class:
>
> makeArrayFromStemArray
>
> This name makes it clear that a stem array is to be processed and that the
> resulting array should not have the stem value with the tail 0.
> (The existting stem method makeArray continues to create an array that
> represents all tails of a stem, including a tail with the value 0.)
>
I'm not sure that using "makeXXX" for the message names is a good idea,
because the request method of the Object class uses the "make" pattern for
class conversions. I'd also try to choose a shorter name (long names are
difficult to remember).

Some things that should be defined:

   - What happens when not all tails have a value? For example, if s.=
   'Default", s.0 = 3, s.1 = 'X", s.2 does not have a value, s.3 = "Z", and a
   is the converted array, what should be the value of a[2]? Both "Default"
   and .Nil are reasonable answers to this question.
   - What happens when the stem has values that are not part of the array,
   like s.this = "that"?
   - When s.0 is not a positive integer, a syntax error should be raised.

1b) In order to create a stem from an ooRexx array the following method
> should be added to the array class:
>
> makeStemArray
>
> This name makes it clear that a stem array is to be created from the array
> items (using the array index values as tails) and adding the 0 tail to
> indicate the number of stem elements.
>
Maybe in this case we could use makeStem directly, as there is no prior
method with that name? Also: what happens when the array is
multi-dimensional? One would think of using several stem indexes, as in
s.1.4.2 = "value", but then it becomes unclear where to store the
dimensions.


> ---
>
> 2) ad using the array class for reading and writing files/streams directly
> ==========================================================
>
> The ooRexx stream class has a method arrayin to allow reading the content
> of a stream into an ooRexx array, and arrayout to write the content of an
> array to a stream. In order to use these methods a stream instance must be
> created first before being able to use the arrayin and arrayout methods and
> closing the stream thereafter. As the purpose of these two methods is to
> simply get the content into and from an array, it may be cumbersome to
> explicitly have to open and close streams in order to just read into or
> write the content of an array.
>
> In order to forego the need to create stream instances in order to read
> the content into an array or an array into a stream or file two class
> methods for the ooRexx array class are proposed:
>
> 2a) In order to read the content of a stream or a file with a single
> message into an array the following method should be added to the array
> class:
>
> arrayin(filename|stream|file[, Lines|chars)
>
> This allows for supplying either a filename (string), an instance of .File
> or .Stream and optionally "Lines" (default, one array element per text
> line) or "chars" (one array element per character).
>
> 2b) In order to write the content of an array to a file or a stream the
> following method should be added to the array class:
>
> arrayOut(filename|stream|file[, Lines|chars)
>
> This allows for supplying either a filename (string), an instance of .File
> or .Stream and optionally "Lines" (default, a text line per per array
> element) or "chars" (the characters of all array elements, without
> appending endoflines).
>

+1

  Josep Maria

> ---
>
> Any comments, thoughts?
>
> ---rony
>
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to