Talk:REXX

From Wikipedia, the free encyclopedia

Contents

[edit] Reserved words

Um, how does it have NO reserved words, especially when "DO" is a reserved word as explained in the article? -- Anon

They are reserved only in context (not globally, as in C). So 'DO' is fine as a variable name, for example. NetRexx takes this further -- keywords are not reserved anywhere, even in context. This means that new keywords can be added to the language at any time, without breaking existing programs. mfc
This works quite well; /**/

say=4;end = 2; do=say+end; do me=end to do; say say + me; end

The result is to print a list of numbers from 6 to 10 (ie say+end to say+do). This is under regina.rexx v 3.3 (which emulates ANSI + a few extensions of OS/2 and Amiga heritage. --Wendy.krieger 08:27, 28 October 2007 (UTC)

[edit] Starting comment

I think that the /* */ start is only required in OS/2 .CMDs. I guess that in Unix the required start is #!/bin/regina or something similar. -- Error

It's required in ARexx, so it's not only OS/2.212.85.68.44 11:59, 19 September 2007 (UTC)
ah, didn't know. Will check with the REXX gurus. -- Viajero 09:03 30 Jun 2003 (UTC)
The "/* ..." is required in VM/CMS (called z/VM these days). VM/CMS systems check the first line of the file to determine which "executor" should be invoked to process the file.
A first line beginning with "&TRACE" triggers the EXEC2 executor, and a first line with with neither &TRACE nor /* at its start drops through to the original EXEC procesor (a sort of BAT precursor). However, if evoked explictity as a macro, etc., the REXX interpreter does not require that the first line start with /*.
I can't speak to the OS/2 question, although I can say that Rexx started on VM and that this mechanism is predates the release of Rexx to the VM sites outside IBM. -- RossPatterson 15:53, 26 Sep 2004 (UTC)
Unix systems require a "#!<something_or_other>" to identify the program that executes the script. In the Regina case, this is typically /usr/bin/rexx, just as in the Perl case it is often /usr/bin/perl. The usage is ancient - shell scripts have begun with "#!/bin/sh" for around 30 years. As to "/* ... */" in Unix, Regina does not require it and neither does Unix. -- RossPatterson 15:53, 26 Sep 2004 (UTC)
(i think its #! /usr/bin/regina)
—Preceding unsigned comment added by 24.51.17.71 (talkcontribs) 21:21, 10 February 2006
Yes, #!/usr/bin/regina will work, if you happen to have Regina installed in /usr/bin (so will /usr/bin/rexx - Regina installs both). But that's a Unix-ism (the whole #!/path/to/interpreter/executable thing), and Regina doesn't require it - you can run a Rexx program simply by typing rexx filename, event if it doesn't have the "sh-bang" line. RossPatterson 02:28, 11 February 2006 (UTC)
Object Rexx [oorexx.org] also allows the "sh-bang" first line. The executable name used by oorexx is rexx, therefore #!/usr/bin/rexx would work. CheyenneWills 20:12, 17 February 2006 (UTC)

I'm pretty sure (although I can't test it) that VM/CMS requires a starting comment only in some circumstances. You can write a Rexx program with no comments at all, compile it, and run it with no problems. I think you can also call a Rexx program without a starting comment from another Rexx program. Therefore, it's not technically a requirement of the language, but of a specific execution environment on the platform, (The "EXEC PROCESSOR") and more because of a historical "accident" than anything else. Had IBM allowed a file type of REXX, it would not have been an issue. Presumably, the rationale was that people would want to rewrite existing EXEC2 macros in REXX and use the same filename and type, so the requirement for interpreted versions was necessary. --Hagrinas 18:05, 27 June 2007 (UTC)

Exactly correct. mfc 17:26, 19 September 2007 (UTC)

The first line of an OS390 rexx script must be /* rexx ..... */. This informs the TSO interpreter that it is REXX and not a CLIST.

Rexx by itself, under Windows or OS/2 does not require a comment at the beginning of the code. This is used by the default command processor to pass commands to the rexx processor. For example, one could create a file with the single line in it:

parse source s; parse version v; say s v

returns WIN32 COMMAND D:\cdata\test.me REXX-Regina_3.3(MT) 5.00 25 Apr 2004

If this is run, eg by invoking the rexx processor, eg regina test.me, then it works as expected. You can also invoke rexx lines inside 4nt or tcmd by @rexx[], as shown below:

The line echo %@rexx[parse source s; parse version v; return s v]

returns WIN32 SUBROUTINE parse REXX-Regina_3.3(MT) 5.00 25 Apr 2004

None the same, the rexx invoked in this way runs in a different shell to that invoked by the command processor by /* rexx */, in as much that it does not have access to the launching process's environment etc. For example, the 4nt command of thhe form set zm=%@rexx[return reverse(value(zm,,SYSTEM))] replaces zm by its string-reverse, using the rexx interpreter to do this. --Wendy.krieger 08:12, 28 October 2007 (UTC)

[edit] Compound variables

This new section replacing the former "Arrays" is much better, thanks. It's a bit long, and I'd prefer to kill the first of the two "dictionary" examples. The 2nd example is compact and documents when it will fail. The 1st example is limited to the REXX concept of words, and ANSI REXX managed to FUBAR this simple concept. -- Omniplex 08:13, 27 June 2006 (UTC)
P.S.: Of course we can just use a separate stem enumeration of defined tails instead of a string of blank (or ANSI else) separated words if necessary, but the more interesting case is to mix it as in the second example.

My reading of this section makes me think that compound variables are more like Java Maps than Vectors. -- ABala 62.189.157.240 15:32, 27 April 2007 (UTC)

More like a Hashtable, although there isn't really any construct in Java (or most other languages) that is a direct equivalent to a collection of Rexx compound variables. Much of the richness comes from the ability to construct tails as if they were additional subscripts of an array or subelements of a hashtable, even though the tail is actually the entire key. RossPatterson 22:14, 27 April 2007 (UTC)
REXX compound variables form one of the stumbling blocks if one comes from an Algol-based system, like C. REXX does not actually do anything more than variable replacement, so if CITY=BRISBANE, then POPULATION.CITY returns POPULATION.BRISBANE. It has no useful way of evaluating the sub-string at access time. If you want a(z+1)=2*a(z), you must do "z1=z+1; a.z1=2*a". Generally, when i want to use a compound string indirectly, i always do it indirectly, ie "z1=0; a.z1=...", rather than "a.0=...". --Wendy.krieger 08:34, 28 October 2007 (UTC)

[edit] Loop constructs

Another, occasionally handy loop construct:

  do 20
    [instructions]
  end

That will simply run the loop 20 times, without any tracking variable.212.85.68.44 11:59, 19 September 2007 (UTC)

Does the do until loop not check if the condition is met before the first iteration, i.e. shouldn't the expansion

  do forever
    [instructions]
    if [condition] then leave 
  end

be enclosed into a if [not condition] do ... end? (I'm just curious, I don't know REXX). 84.150.122.29 21:02, 19 January 2007 (UTC)

Yes, a do until loop checks the condition at the bottom of the loop, so it is exactly equivalent to the code you entered above. If you want a test at the top of the loop, you use do while instead. As Cowlishaw's book says,
Example:
   do i=1 to 10 by 2 until i>6
     say i
     end
   /* Would display: 1, 3, 5, 7 */

RossPatterson 21:13, 20 January 2007 (UTC)

Thanks, I had somehow not noticed that testing before the loop, and then again at the bottom during every iteration amounts to the same as testing at the top (well, add a caveat about values of induction variables etc.) 84.150.104.35 19:38, 22 January 2007 (UTC)

[edit] function packages

Shouldn't the article mention the necessity of third party libraries, for additional functions, and to interface with specific OS services and software? I guess that should be in the Features section; i see a brief mention in the paragraph on the Interpret verb. I'm not adding it myself because at present i can't find the right wording, and am not quite sure of how to not make a mistake. Moreover, perhaps it is considered evident, that a programming language limit itself to only general logic processing?

Some buzzwords/articles to point to:

--Jerome Potts 23:19, 21 July 2007 (UTC)

[edit] Updating of variables by host commands

I remember that, on VM/CMS, not all external host commands would be able to set Rexx variables, there was some kind of requirement, but i don't remember the terminology for the mechanism. Does anyone know, and if so, is it something which could/should be present in this article? And i don't know whether this was an issue with the later implementations of Rexx, on other OSes.

--Jerome Potts 23:28, 21 July 2007 (UTC)

  • REXX variables are accessed by the EXECCOMM interface on VM. On a related note, I'm puzzled by the statement that VALUE()'s "main purpose is to read and set environment variables." VALUE() was around as a way to resolve symbols for years before arguments were added to allow it to set and retrieve external variables. Not R (talk) 21:54, 28 January 2008 (UTC)