Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object REXX
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Features == Above all, ooRexx offers OOP features such as [[Inheritance (object-oriented programming)|subclassing]], [[Polymorphism (computer science)|polymorphism]], [[Encapsulation (computer programming)|data encapsulation]] and [[multiple inheritance]] via [[mixin]] [[Class (computer programming)|classes]]. The interpreter includes the <code>rexxc</code> utility, which makes it possible to compile ooRexx programs and optionally encode the result as [[base64]], a source-less file that starts faster since the initial parsing and compiling has already been done.<ref name=":9" /> === Parsing === The <code>PARSE</code> keyword instruction makes it possible to quickly and flexibly parse a string and assign parts of it to variables in a single step.<ref name="fosdick" /> Subsequent instruction is used to specify the source of the string, for example <code>ARG</code> for arguments that are listed when the program or function is called, <code>VAR</code> for variables, <code>PULL</code> for data queues or standard input (typically the keyboard), <code>VALUE</code> for any expression. When using <code>VALUE</code>, the <code>WITH</code> keyword is required to specify the end of an expression, followed by a parsing pattern. This pattern can be a list of variables, a position number or literal delimiters; it is possible to use these patterns in combination. Optionally, the upper and lower case of the string can be converted before parsing.<ref name=":2" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> str = "Person: Rick McGuire" /* parse string using the literal ":" and blanks between words into variables a ("Person"), b ("Rick"), and c ("McGuire") */ parse var str a ":" b c /* parse by literal and blank */ say b c /* output: Rick McGuire */ </syntaxhighlight> === Procedure and function === ooRexx provides a new way to define procedures and functions that are not specific to a particular class by using the <code>::ROUTINE</code> [[Object REXX#Instructions|directive]]; unlike the older <code>PROCEDURE</code>, code defined with <code>::ROUTINE</code> has an implicit <code>RETURN</code> at the end. The <code>CALL</code> instruction can be used to invoke a routine as a procedure. In addition, routines that return values via the <code>RETURN</code> keyword instructions can be called using function calls by specifying the name of the routine followed by parentheses. The content within the brackets is passed as an argument to a routine. While the <code>PARSE ARG</code> instruction can be used to parse received string arguments and assign them to variables, the newer <code>USE ARG</code> must be used for objects of other types. In addition, the <code>STRICT</code> option can be used to limit the number of arguments that must match the number of specified names.<ref name=":2" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1">call DoSomething /* "CALL" keyword instruction */ table = .stem~new /* Stem object for indsum */ table[1] = 2; table[2] = 4 say indsum{table,1.2) /* function call requiring use arg */ say dirsum(2,4) /* either parse arge or use arg okay */ ::Routine DoSomething /* "ROUTINE" directive (procedure) */ say "I did something!" /* output: I did something! */ /* Implicit return because next */ /* statement is a directive. */ ::Routine dirsum /* "ROUTINE" directive (function) */ parse arg first, second /* Valid because both are strings. */ return first+second ::Routine indsum /* "ROUTINE" directive (function) */ use strict arg table, first, second /* can't use parse arg with stem arg */ Sum = table{first} + table[second] /* do calculation */ return Sum /* "RETURN" result */</syntaxhighlight> === Class and Method === The <code>::CLASS</code> [[Object REXX#Instructions|directive]] followed by a class name causes the interpreter to define a new class. After the class name, options such as <code>METACLASS</code>, <code>SUBCLASS</code>, <code>MIXINCLASS</code>, <code>ABSTRACT</code> and <code>INHERIT</code> can be set in order to use OOP features. The <code>::METHOD</code> directive can be used to define a new class method that is associated with the last <code>::CLASS</code> directive. The <code>::ATTRIBUTE</code> directive is used to define an [[Mutator method|accessor method]] that can retrieve or assign an object variable. Using the <code>EXPOSE</code> instruction, an object variable can be directly exposed to a method.<ref name=":2" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> d = .dog~new("Bella") /* create and assign a dog */ d~bark /* send bark message */ say d~name /* output: Bella */ ::class dog /* class directive */ ::attribute name /* attribute directive */ ::method init /* object initiation method */ Expose name /* exposes name of dog */ use arg name /* assigns "Bella" to name */ ::method bark /* method directive */ Expose name say Name "goes woof!" /* output: Bella goes woof! */ </syntaxhighlight> === Multi-threading === Conceptually, ooRexx provides object-based [[Concurrency (computer science)|concurrency]], according to which objects have independent resources to execute methods and can communicate with each other using the messaging paradigm. Several objects can be active at the same time and exchange messages for [[Synchronization (computer science)|synchronization]].<ref name=":2" /> Concurrency can be achieved with the <code>REPLY</code> keyword instruction, which causes an early return from a method while its remainder continues to execute in a new thread. Alternatively, the keyword instruction <code>GUARD</code> can be used to mark a method as unprotected so that it can be executed together with other methods of the same class. Finally, using the <code>START</code> method (Object or Message class) causes the recipient to process the received message in a separate thread, thus also enabling concurrency.<ref name=":2" /> === Tracing === As in classic Rexx, the <code>TRACE</code> keyword statement and the built-in <code>TRACE()</code> function facilitate debugging. Both allow control over the level of detail and enable interactive debugging at runtime.<ref name=":6">{{Cite book |last1=Flatscher |first1=Rony G. |last2=Winkler |first2=Till |chapter=Devising a TraceObject Class for Improved Runtime Monitoring of ooRexx Applications |date=2024 |title=Proceedings of the 7th ACM International Workshop on Verification and Monitoring at Runtime Execution |chapter-url=https://dl.acm.org/doi/pdf/10.1145/3679008.3685543 |page=19-24|doi=10.1145/3679008.3685543 |isbn=979-8-4007-1119-0 }}</ref> When interactive debugging, the interpreter pauses after most instructions that are traced.<ref name=":2" /> ooRexx 5.1.0 introduces the <code>TraceObject</code> class, which provides additional information such as timestamps, interpreter instances, thread IDs on which messages are dispatched, and the state of the guard locks for tracing multi-threaded programs. This class makes it easier to determine which method is currently guarded and blocked.<ref name=":6" /> The ooRexx debugger, which is also included in the "net-oo-rexx" bundle, is based on Trace and offers a [[graphical user interface]] (GUI) that uses the [[Object REXX#Java|Java bridge]] to facilitate debugging on all platforms.<ref name=":12" /><ref>{{Cite web |date=2025-01-26 |title=ooRexx Debugger |url=https://sourceforge.net/projects/oorexxdebugger/ |access-date=2025-02-02 |website=SourceForge |language=en}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)