This project started many years ago - the earliest file I have located
was dated 21 Sept. 2009 - and was initially only concerned with
converting one type of ordered collection to another. Each of the four
classes - array, list, queue and circularQueue - provided a different
"view" of a sequence of items (and, hence, different methods to operate
on them) but they all shared the property that the order of the items
was what was significant. I thought it would be useful to be able to
easily change "views" and came up with the idea of a 'from' class
method, similar to the 'of' class method but taking an ordered class
instance as its argument instead of an enumeration of the items. The
code was relatively straight forward but making the 'from' method
available took some time. I finally settled on creating a mixin class
with the single 'from' class method and then four sub-classes that
inherited from the mixin class.
As with all projects, they are never 'finished' and this one wasn't
either. I realized that stem arrays are often used in place of one of
the four ordered collection classes and that converting to or from a
stem array would also be useful. Allowing my 'from' method to take a
stem array instance as its argument was the next step and it solved the
conversion "from" part but to allow conversion "to" a stem array
required a different approach. I experimented with a 'toStem' (instance)
method but wasn't happy with the asymmetry so I created a 'from' class
method for the stem class with the same syntax. This required another
mixin class and another sub-class but it worked.
As this solution provides the functionality requested in the original
post, I offer it as a way to not "reinvent the wheel" so to speak. In
my next post, I will include the code for the two 'from' methods and
provide some (additional) comments on how it works and some examples of
its use. Stay tuned...
On 3/11/2025 9:27 AM, Gilbert Barmwater wrote:
Thanks for the interest in my approach. My plan is to post the code -
two class methods, both named 'from' - to this list with a better
description of where they are added and some examples of how one might
use this functionality. I'm hoping to do so later today depending on
the time I have available.
Gil
On 3/11/2025 8:26 AM, Josep Maria Blasco wrote:
Hi Rony,
Missatge de Rony G. Flatscher <rony.flatsc...@wu.ac.at> del dia dl.,
10 de març 2025 a les 17:44:
Hi Josep Maria,
On 09.03.2025 14:40, Josep Maria Blasco wrote:
Missatge de Rony G. Flatscher <rony.flatsc...@wu.ac.at> del dia
dg., 9 de març 2025 a les 14:04:
(cut)
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.
Yes, that is the reason why using that name.
Ah, but a class called "ArrayFromStemArray" does not exist, and
that breaks the "make" semantics. Rexxref 5.4.1.18 "request"
says "Any conversion method *must return an object of the
requested class*. For example, makeArray must return an array"
(emphasis mine). But, since there is no such thing as an
ArrayFromStemArray class, this could be misleading.
Yes. The conversion method must start with "make" and be followed
by the classid (a string) supplied as argument to the .Object's
request method.
This protocol could be used for creating an array from a stem (by
implementing a method "make" || supplied_classId_as_arg, however,
there is already a makearray method defined for stem. Hence the
first idea to add the variant to the name of the conversion
method yielding "makeArrayFromStemArray". The reason being that
.Object's request method does only accept the classid argument
and by using another name that includes the intent
("fromStemArray") one could add another make conversion method to
the stem class. However, I concur that a) the name becomes too
long and b) probably "classid" should be an existing classid. :)
Then it becomes possibel to change the name of the method tonot
start with "make" hence not adhering to the request protocol.
Exactly!
In the meantime Gil's idea seems to be interesting.
I like it too. Very elegant, simple and easy to remember.
Josep Maria
---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
--
Gil Barmwater
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel
--
Gil Barmwater
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel