While hunting up something else I ran across something the reference manual calls "POSIX character classes", representing particular sets of characters that a programmer might have a use for, such as UPPER or BLANK. I want to experiment with them, but for the life of me I can't figure out how.
Ok, it's a dumb question, but none of my experiments work. If I want to initialize a string as UPPER, for example, what's the syntax?
While hunting up something else I ran across something the reference
manual calls "POSIX character classes", representing particular sets of
characters that a programmer might have a use for, such as UPPER or BLANK.
I want to experiment with them, but for the life of me I can't figure out
how.
Ok, it's a dumb question, but none of my experiments work. If I want to
initialize a string as UPPER, for example, what's the syntax?
Sorry, I'm puzzled.
~~~
say .string~upper
ABCDEFGHIJKLMNOPQRSTUVWXYZ
~~~
just as you showed, but w/o ~upper ...
~~~
say .string
The String class
Just as would happen with any other class object, for example,
say .array
say .directory
~~~
why not A..Z in lower case?
Why would you expect that to happen? The class object just displays its
string identity. If you want the set of characters that oorexx recognizes
as lower case, use the lower method.
say .string~lower
~~~
say .string~new
+++ Interactive trace. Error 93: Incorrect call to method.
+++ Interactive trace. Error 93.903: Missing argument in method;
argument 1 is required.
~~~
Ok, that's a RTFM case
~~~
say .string~lower
abcdefghijklmnopqrstuvwxyz
~~~
-- quite odd me think -- AND! why a..z only? All else are no strings? For
example:
.string~upper returns the set of characters that oorexx recognizes as
uppercase. e.g, those characters that will be affected by PARSE LOWER or
the LOWER() BIF. .string~lower returns the set of characters that would be
affected by PARSE UPPER or the UPPER() BIF.
I have no idea what you are asking here. Yes, they are strings, but what's
your point here? In the Rexx language, only the characters returned by
.string~upper are considered uppercase characters and only the characters
returned by .string~lower are considered lowercase characters.
I think I'm starting to understand your confusion. I believe you are
confusing the class methods of the .String class with the instance methods
of strings. The POSIX methods are class methods of the .String class and
just return a string object containing the set of characters in that
category. For example, upper, lower, alpha, etc. Note that these are the
same strings you can obtain from XRANGE('upper'), etc.
String objects have instance methods that perform functions on individual
string instances. For example, substr, insert, and yes, upper and lower.
The upper and lower methods convert the strings up uppercase and lowercase,
respectively, but only affect the characters that Rexx considers upper and
lower case. So, for example,
say .String~upper~lower
will display the characters "a..z". The UPPER method of the .String class
returns the string "A..Z". That string instance then receives the message
"LOWER", which invokes the string LOWER instance method. That method
lowercases all of the uppercase characters in the string, returning the new
string object "a..z".
I think I'm starting to understand your confusion.
Sorry if my interjection was too imprecise. And thank you for your lengthy reply. For me grown old with REXX on VM/CMS this ooRexx still offers some amazement. When I take ~upper as a message then there must be an object to obey the order. Therefore -- since the result is "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- the corresponding object was a string of 'a..z'.
Not at all, I grasped now with your help. With .string the messages ~upper and ~lower are not the orders to transliterate minuscule to capital letters or opposite, it's "show a string of candidates able to obey this order." -- Uh!
BTW, some trivia, the German alphabet has one letter extra in contrast to the Swiss, the "Eszett" ß, a ligation of lower case 's' and 'z'. When changing to uppercase it was replaced by double 'S', what is not possible for family names. Thus German authorities (clever as they are) invented an "uppercase Eszett" so to print passports with all names in capital letters. So a future ooRexx has an additional candidate to obey ~upper and ~lower.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"show a string of candidates able to obey this order." - close but not quite :-) It's more like "return the value of the class attribute named ...". They could have been named BigLetters and SmallLetters vs. upper and lower just as well; there isn't any correspondence between the "upper"/"lower" instance methods and the "upper"/"lower" class attributes other than they are spelled the same. HTH
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, what is object-oriented programming? Taking interacting real-world objects as role model, so there must be room for misconceptions to give coincidence a chance to do a good deed ;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
While hunting up something else I ran across something the reference manual calls "POSIX character classes", representing particular sets of characters that a programmer might have a use for, such as UPPER or BLANK. I want to experiment with them, but for the life of me I can't figure out how.
Ok, it's a dumb question, but none of my experiments work. If I want to initialize a string as UPPER, for example, what's the syntax?
Ok, I said it was a dumb question, and I'm sure I'll kick myself as soon as I see it done right, but ...?
str = .string~upper
Those are just methods of the string class that return the different
character sets.
Rick
On Thu, Jul 18, 2024 at 6:00 PM Robert Bridges bobbridges@users.sourceforge.net wrote:
Sorry, I'm puzzled.
just as you showed, but w/o ~upper ...
why not A..Z in lower case?
Ok, that's a RTFM case
-- quite odd me think -- AND! why a..z only? All else are no strings? For example:
IMO strings, strings, strings. No?
On Thu, Jul 18, 2024 at 10:45 PM m-stgt m-stgt@users.sourceforge.net
wrote:
Just as would happen with any other class object, for example,
say .array
say .directory
say .string~lower
~~~
I have no idea what you are asking here. Yes, they are strings, but what's
your point here? In the Rexx language, only the characters returned by
.string~upper are considered uppercase characters and only the characters
returned by .string~lower are considered lowercase characters.
Rick
I think I'm starting to understand your confusion. I believe you are
confusing the class methods of the .String class with the instance methods
of strings. The POSIX methods are class methods of the .String class and
just return a string object containing the set of characters in that
category. For example, upper, lower, alpha, etc. Note that these are the
same strings you can obtain from XRANGE('upper'), etc.
String objects have instance methods that perform functions on individual
string instances. For example, substr, insert, and yes, upper and lower.
The upper and lower methods convert the strings up uppercase and lowercase,
respectively, but only affect the characters that Rexx considers upper and
lower case. So, for example,
say .String~upper~lower
will display the characters "a..z". The UPPER method of the .String class
returns the string "A..Z". That string instance then receives the message
"LOWER", which invokes the string LOWER instance method. That method
lowercases all of the uppercase characters in the string, returning the new
string object "a..z".
Rick
On Thu, Jul 18, 2024 at 10:45 PM m-stgt m-stgt@users.sourceforge.net
wrote:
Sorry if my interjection was too imprecise. And thank you for your lengthy reply. For me grown old with REXX on VM/CMS this ooRexx still offers some amazement. When I take
~upper
as a message then there must be an object to obey the order. Therefore -- since the result is "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- the corresponding object was a string of 'a..z'.Not at all, I grasped now with your help. With
.string
the messages~upper
and~lower
are not the orders to transliterate minuscule to capital letters or opposite, it's "show a string of candidates able to obey this order." -- Uh!BTW, some trivia, the German alphabet has one letter extra in contrast to the Swiss, the "Eszett" ß, a ligation of lower case 's' and 'z'. When changing to uppercase it was replaced by double 'S', what is not possible for family names. Thus German authorities (clever as they are) invented an "uppercase Eszett" so to print passports with all names in capital letters. So a future ooRexx has an additional candidate to obey
~upper
and~lower
."show a string of candidates able to obey this order." - close but not quite :-) It's more like "return the value of the class attribute named ...". They could have been named BigLetters and SmallLetters vs. upper and lower just as well; there isn't any correspondence between the "upper"/"lower" instance methods and the "upper"/"lower" class attributes other than they are spelled the same. HTH
Well, what is object-oriented programming? Taking interacting real-world objects as role model, so there must be room for misconceptions to give coincidence a chance to do a good deed ;)
Got it, thanks.