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!
== Design philosophy == ooRexx follows the [[Design#Philosophies|design philosophy]] of classic Rexx to create a "[[Human-centered computing|human-centered]]" programming language that is easy to learn, code, remember and maintain. This is achieved, in part, by keeping the language small and following the [[principle of least astonishment]].<ref name="fosdick"> {{Cite book |last=Fosdick |first=Howard |url=https://rexxinfo.org/Rexx_Programmers_Reference.pdf |title=Rexx Programmer's Reference |publisher=Rexx Language Association |year=2024 |isbn=979-898611913-7 |edition=2nd}}</ref><ref name=":7">{{Cite journal |last=Cowlishaw |first=Mike |date=1987 |title=The design of the REXX language |url=https://dl.acm.org/doi/pdf/10.1145/24686.24687 |journal=ACM SIGPLAN Notices |volume=22 |issue=2 |pages=26β35|doi=10.1145/24686.24687 |url-access=subscription }}</ref> A readable syntax is enabled by being case-insensitive, free-form, requiring as little punctuation as possible, and using instructions that are straightforward English.<ref name=":7" /> In addition, it is a [[dynamic programming language]] that offers [[Flexibility (engineering)|flexibility]] and allows to focus on development rather than language constraints. Following the "documentation before implementation" design principle of classic Rexx, ooRexx offers comprehensive documentation in accordance with the IBM Style Guide that includes [[Syntax diagram|syntax diagrams]] and examples.<ref name=":7" /><ref name=":2">{{Cite book |last1=Ashley |first1=W. David |url=https://sourceforge.net/projects/oorexx/files/oorexx-docs/5.0.0/rexxref.pdf |title=ooRexx Documentation 5.0.0 Open Object Rexx Reference |last2=Flatscher |first2=Rony G. |last3=Hessling |first3=Mark |last4=McGuire |first4=Rick |last5=Peedin |first5=Lee |last6=Sims |first6=Oliver |last7=Wolfers |first7=Jon |publisher=RexxLA |year=2022}}</ref> === Instructions === As in classic Rexx, there are assignment instructions, keyword instructions and command instructions. In line with the desire to keep the language small, ooRexx 5.0.0 has only thirty keyword instructions.<ref name=":2" /> Unlike many other languages, no keywords are reserved, so keyword instructions such as <code>DO</code>, <code>SAY</code>, <code>END</code> and <code>IF</code> for example can be used as variable names during an assignment. This avoids having to memorize a long list of [[Reserved word|reserved words]].<ref name=":4" /> An assignment is used to set or change the value of a variable. The equal sign (<code>=</code>) is used to create an assignment instruction which can be used in combination with eleven operators for extended assignment sequences such as <code>+=</code>, <code>-=</code>, <code>*=</code> and others. Keyword instructions such as <code>ARG</code>, <code>PARSE</code>, <code>PULL</code> or <code>USE</code> have the same effect as assignments.<ref name=":2" /> In cases where an instruction is neither an assignment nor a keyword instruction, it must be a string literal or a valid expression which is considered a command instruction, which causes the interpreter to pass the string to the operating system for execution and set a variable <code>RC</code> for the return code. In addition, the <code>ADDRESS</code> instruction allows commands to be redirected to specific command environments such as [[Bourne shell|Bourne Shell]], [[Bash (Unix shell)|Bash]], [[Z shell|Z-Shell]], [[Cmd.exe|Command Prompt]] and others, some editors including [[ISPF]], [[Time Sharing Option|TSO]] EDIT, [[XEDIT]] and its [[XEDIT#PC and Unix adaptations|adaptations]], as well as intercepting errors.<syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> a = "hello world" /* assignment instruction */ do i = 1 to 2 /* keyword instruction "DO" */ say "round #" i":" a /* keyword instruction "SAY" */ end /* keyword instruction "END" */ "echo Hello World" /* command to operating system */ say "RC:" rc /* command's numeric return code */ </syntaxhighlight>In addition to the three instruction types of classic Rexx, ooRexx adds [[Directive (programming)|directive]]{{efn|As of 5.0.0, ooRexx has the <code>::ANNOTATE</code>, <code>::ATTRIBUTE</code>, <code>::CLASS</code>, <code>::CONSTANT</code>, <code>::METHOD</code>, <code>::OPTIONS</code>, <code>::REQUIRES</code>, <code>::RESOURCE</code> and <code>::ROUTINE</code> directives.}} instructions which need to be placed at the end of the program. After loading and the syntax check, the interpreter executes all defined directives to set up the execution environment for the program before further instructions are executed. Directives can be used to define [[Object REXX#Procedure and function|routines]], [[Object REXX#Class and Method|classes]], [[Object REXX#Class and Method|methods]], attributes or execution options like the number of digits to use in arithmetics. To make directive instructions readily recognizable, they are introduced with two consecutive colons (<code>::</code>).<ref name=":2" /> To facilitate the [[reusability]] of code, the <code>::REQUIRES</code> directive allows the integration of another Rexx program (also known as a package) or an external (native) library. This directive causes the interpreter to make every routine and class that specifies the <code>PUBLIC</code> option of the denoted Rexx program (package) to become directly accessible. External packages usually use the file extension <code>.cls</code>, for example <code>::requires "csvstream.cls"</code> or <code>::requires "json.cls"</code>. Some [[Object REXX#External packages and libraries|external packages and libraries]] are delivered with the ooRexx interpreter. === Free-form === ooRexx has a [[Free-form language|free-form syntax]] where the positioning of the program code is irrelevant, which allows a high degree of flexibility. Before execution, the interpreter merges multiple unquoted blanks into one, while a character string enclosed in [[Quotation mark|quotation marks]] (single or double) is not changed. Concatenation can be requested explicitly with two vertical bars (<code>||</code>), or implicitly by separating terms with spaces or by abutting terms. Optionally, clauses can be spread over several lines by using the comma (<code>,</code>) or the minus sign (<code>-</code>) as a continuation character, or several clauses can be used in a single line, separated by a semicolon (<code>;</code>).<ref name=":2" /> Since a free-form language provides flexibility and requires fewer syntactic rules to be considered, it is assumed that it eases the learning effort by reducing the [[Cognitive load#Intrinsic|intrinsic cognitive load]].<ref name=":3">{{Cite journal |last1=Winkler |first1=Till |last2=Flatscher |first2=Rony G. |title=Cognitive Load in Programming Education: Easing the Burden on Beginners with REXX |url=https://research.wu.ac.at/files/46150789/CECIIS_CLT_REXX.pdf |journal=Central European Conference on Information and Intelligent Systems}}</ref> <syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1">say "Hello World!" /* output: Hello World! */ say " This" 'is' - /* trailing dash for continuation */ "REXX" || "!" /* output: This is REXX! */</syntaxhighlight> === Case-insensitive === As classic Rexx, ooRexx is a [[Case sensitivity#In programming languages|case-insensitive programming language]]. Accordingly, the ooRexx interpreter capitalizes all characters outside quotation marks (single or double) and ignores case for instructions, variable names and all other aspects of the language. Only sequences within quotation marks are treated as literal strings and are not changed during processing.<ref name=":2" /> Because the cases do not need to be differentiated, fewer additional details need to be learned and frustrating syntax errors are avoided.<ref name=":3" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> a = "This is" rexx! Say A /* output: This is REXX! */ SAY a /* output: This is REXX! */ </syntaxhighlight> === Everything is an Object === While classic Rexx follows the "Everything is a String" philosophy and has [[String (computer science)|string]] as its only data type, ooRexx considers everything as objects, including non-string objects such as arrays, streams and many more. Objects are manipulated using methods instead of traditional functions. In ooRexx, a string variable is a reference to a string object and does not need to be declared, which reduces the effort for programmers compared to [[Type system|strictly typed languages]].<ref>{{Cite journal |last1=Stefik |first1=Andreas |last2=Siebert |first2=Susanna |date=2013 |title=An empirical investigation into programming language syntax. |url=https://dl.acm.org/doi/10.1145/2534973 |journal=ACM Transactions on Computing Education |volume=13 |issue=4 |pages=1β40 |doi=10.1145/2534973|url-access=subscription }}</ref> A string object can be of any length and contain any characters, including numerical values. It is therefore possible to change numerical values with string manipulations and methods of the <code>String</code> class. In addition, a string variable can contain any type of expression, including executable instructions, which can be evaluated or executed with the <code>INTERPRET</code> keyword instruction.<ref name=":2" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> a = 2 /* string with numerical value */ a = a || '0' /* resulting string: 20 */ str = "do i = 1 to "a"; say i; end" /* string contains loop instruction */ interpret str /* interpret string: counts to 20 */ </syntaxhighlight> === Message paradigm === Similar to the messaging paradigm implemented by [[Alan Kay]] in Smalltalk, everything in ooRexx is an object that can be communicated with. The notion of sending messages to objects as if they were living beings helps beginners to learn OOP concepts.<ref name=":4">{{Cite journal |last1=Flatscher |first1=Rony G. |last2=Winkler |first2=Till |title=Employing the Message Paradigm to Ease Learning Object-oriented Concepts and Programming |url=https://research.wu.ac.at/files/64505159/mipro24_9194_Flatscher_Winkler_EmployingMessageParadigm_final-4.pdf |journal=In 2024 47th MIPRO ICT and Electronics Convention (MIPRO) |pages=1244β1249}}</ref> In contrast to Smalltalk, there is an explicit message operator, the tilde (<code>~</code>), where the receiving object is placed to the left of it and the result of the operation is returned. Sending a message leads to the activation of a method with the corresponding method name and to the manipulation of the receiving object. Like Smalltallk, ooRexx messages can be cascaded if two tildes (<code>~~</code>) are used instead of one, returning the object that received the method rather than the result produced.<ref name=":9">{{Cite book |last1=Ashley |first1=W. David |url=https://sourceforge.net/projects/oorexx/files/oorexx-docs/5.0.0/rexxpg.pdf |title=ooRexx Documentation 5.0.0 Programmer Guide |last2=Flatscher |first2=Rony G. |last3=Hessling |first3=Mark |last4=McGuire |first4=Rick |last5=Peedin |first5=Lee |last6=Sims |first6=Oliver |last7=Wolfers |first7=Jon |date=2022 |publisher=RexxLA}}</ref> The default behavior of most methods can be changed by specifying an option, which can be either spelled out or abbreviated and is not case-sensitive. When reading code, this enables a literal understanding and reduces the learning effort for beginners, as there is no need to learn the meaning of abbreviations.<ref name=":3" /> For example, the method with the name <code>strip</code> removes leading and trailing blanks by default. This behavior can be changed, for example, by specifying <code>"leading"</code> or <code>"l"</code> as an option. While functions are nested in classic Rexx, messages can be chained in ooRexx, which improves the readability of a [[Statement (computer science)|statement]].<ref name=":4" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> a = " I am ooRexx!" say a /* output: I am ooRexx! */ say a~Strip("Leading") /* output: I am ooRexx! */ say a~strip("l")~reverse /* output: !xxeRoo ma I */ </syntaxhighlight> === Cross-platform interoperability === ooRexx is designed to retain [[Rexx#Features|all the features of classic Rexx]] and essentially complies with the ANSI standard for the Rexx language (X3.274-1996, "Programming Language REXX").<ref name=":0" /> In contrast to an optional specification in the ANSI standard, ooRexx does not allow characters such as <code>@</code>, <code>#</code>, <code>$</code> and <code>Β’</code> in symbols. While in classic Rexx the expression <code>b. = a.</code> results in <code>b.</code> being assigned the default value of <code>a.</code>, the interpreter makes <code>b.</code> an alias for <code>a.</code>. In addition, ooRexx allows <code>--</code> as a comment mark and <code>-</code> as a line continuum, which are not specified in the standard.<ref name=":0" /> Classic Rexx scripts usually run without changes under ooRexx, making it easy to migrate to OOP features at the desired rate while preserving the time invested in the original code.<ref name="fosdick" /> As the interpreter supports a large number of platforms, code migration to these is also feasible.
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)