Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Call differences between rexx implementations
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 28th February 04:03
ian
External User
 
Posts: 1
Default Call differences between rexx implementations



Hi -

I had a problem with how I was calling a routine, and found some
differences between regina, ibm, and reginald. Here's sample code:

/* calltest.rex: Test rexx call interface */
parse version ver
say "Version: " ver
call myfunc("One", "Two")

return

myfunc: procedure
parse arg a , b ;
say "ARG 1:" a ;
say "ARG 2:" b ;
return

This works in reginald, but not in the other two.

Change the call to this:

call myfunc "One", "Two"

and it works in all three.

[OOps, I just tested the program on an older version of Regina
(REXX-Regina_2.0 4.80 4 May 2000), on my home computer, and it works

As a function call, you'd state it this way:

x = myfunc("One", "Two");

and modify the routine to return something.

Intuitively, calling the same code should, I think, be possible using
the same notation. The older version of Regina seems to have agreed. In
addition, the call format I prefer [ call myfunc("One", "Two") ] is more
readable, and conforms more closely to how other languages do it.

Is this part of an old debate, or is it something that anyone else has
thoughts on?

Thanks,

Ian
  Reply With Quote


  sponsored links


2 28th February 04:03
graham
External User
 
Posts: 1
Default Call differences between rexx implementations



Have you looked at the description of REXX's CALL instruction? The
syntax you've used isn't valid. The first thing after CALL is either a
name (i.e. a literal) or, in later REXX versions, a variable name in
parentheses. Yours is neither of these. Reginald isn't REXX (although it
is similar) and is free to follow its own rules. For it's part, it
appears Regina once had a bug which allowed it to accept the invalid
syntax, but doesn't have that bug any more.

Graham.

--
*-* Please remove spam free prefix before replying *-*
  Reply With Quote
3 28th February 04:03
florian_große-coosmann
External User
 
Posts: 1
Default Call differences between rexx implementations


Graham schrieb:

You are right, Graham. ANSI doesn't allow it and it don't make any sense.
Something like "call myfunc (whatever)" will be evaluated as
"x = (whatever); call myfunc x". The parenthesis indicate a local
grouping of terms. A more obvious example is "call numwork (2+3)*4"
which shows the true problem: Is "call numwork(x,y)+1" a typo of the
comma or is the trailing "+1" the problem?

On the other hand, try "call format(2+3)*2; say result" in reginald.
Regina made it wrong some versions ago. The correct output is "10",
not an error message.

Because of this typical bug you can assume that reginald is based on
Regina, although reginald's source code isn't published to verify
this.

Rexx's grammar doesn't allow anything else to interpret. If you prefer
using parenthesis all times you should use "dummy = myfunc(x, y)". But
this may lead to errors if the called routine doesn't return a value at
all.

Cheers, Florian
  Reply With Quote
4 28th February 04:03
jeff glatt
External User
 
Posts: 1
Default Call differences between rexx implementations


The older version of Regina supported using parentheses with the CALL keyword,
but in the original version of IBM's REXX, that was not supported. For "Classic
REXX", parentheses around arguments are allowed only if you're calling a
function (that returns a value), in which case you don't use the CALL keyword
at all. (And when not using CALL, the return value must be used in an
expression, or variable assignment, or else it will be passed on to the
operating system if you don't specifically do something with it). For example,
these are ok in Classic REXX:

call myfunc 'One', 'Two' /* A subroutine call */
ret = myfunc('One', Two') /* A function call and assignment */
DO myfunc('One', 'Two') /* Specifically using the return value of function call
*/
myfunc('One', 'Two') /* A function call, and the return value is passed to the
operating system to execute as the name of some "command' */

This is not ok in Classic REXX:

CALL myfunc('One', 'Two') /* No parentheses around args when using CALL */

Some of the syntax of REXX is a bit odd, inconsistent, and anachronistic
compared to more modern, object-oriented languages. REXX was originally
designed to be a glorified batch language which is why it does something truly
odd that no other language does, which is to tell the operating system to
execute (as a command) anything that the interpreter doesn't know to be a REXX
keyword, subroutine, or function, including a function's return value that you
don't specifically use in some way. That's a good thing in a batch language
that is designed to pipe the output of some "system command" to another system
command, such as to execute a 'dir' command to get a directory listing and then
pipe that to a 'sort' command to sort the text in some way. Obviously, REXX was
designed with some other purpose than to make programs like the event-driven
GUI software that is today's standard.

Apparently, the original programmer of Regina thought that it would be less
confusing to REXX programmers if they could always put parentheses around
arguments passed to a subroutine or function, instead of having to remember the
details of this oddly anachronistic design of REXX. (It wasn't a "bug". It was


Later, some people threw together a sort of "standard" syntax for REXX which
mostly adopted Classic REXX's syntax, and therefore specified that parentheses
could not be used around arguments when the CALL keyword is used. So Mark
Hessling subsquently removed the option from later versions of Regina in order
to make it compliant with this "standard". (I favor allowing the choice.
There's no sense moving backward to less choice).

Personally, I think that there's no real usefulness to having REXX
automatically ship return values to the operating system to execute as a
command, and in fact, it's a pain in the ass and very often a detriment to
newbie REXX programmers. (I can't tell you how many people say "Why does a
console window keep popping up when I run my program, with this error message
that it can't find some command?", and it's because they forgot to do something
with the return value of a function, and yet, didn't use the CALL keyword
either. The CALL keyword is a pain in the butt, and nothing like it exists in
popular languages such as C/C++ or java or C#).

That's why, with Reginald, you can put the following line at the start of your
REXX script:

ADDRESS NULL

And then you can call functions all you want, and never have to use the CALL
keyword. You can totally forget that it exists, which is a good thing as far as
I'm concerned.

You can do...

myfunc('One', 'Two')

....and be assured that the operating system won't be given that return value to
execute as a command.

I don't know as if this will work in Object Rexx or Regina, but it ideally
should.

(Now you know why all of the REXX scripts I write for my own use start out with
ADDRESS NULL).

Incidentally, Reginald is definitely REXX in that it will execute any script
written for Classic REXX. But it also has various extensions and additional
features that have proven invaluable to people who have chosen to use this
interpreter.
  Reply With Quote
5 28th February 04:03
shmuel (seymour j.) metz
External User
 
Posts: 1
Default Call differences between rexx implementations


In <8kGnb.122146$k74.40470@lakeread05>, on 10/28/2003
at 10:18 PM, ian
<spammapsglenizrainmapsspammaps@spamerolsspammaps. invalid> said:

The other two comply with the ANSI standard; your call has incorrect
syntax. It should have been

call myfunc "One", "Two"

--
Shmuel (Seymour J.) Metz, SysProg and JOAT

Unsolicited bulk E-mail will be subject to legal action. I reserve
the right to publicly post or ridicule any abusive E-mail.

Reply to domain Patriot dot net user shmuel+news to contact me. Do
not reply to spamtrap@library.lspace.org
  Reply With Quote
6 28th February 04:03
shmuel (seymour j.) metz
External User
 
Posts: 1
Default Call differences between rexx implementations


In <q7oupvschd05oudgdmqelhffn4qjjlbjee@4ax.com>, on 10/29/2003
at 02:19 AM, Jeff Glatt <jglatt@spamgone-borg.com> said:

Not exactly a random assortment of people. It was ANSI.

Yea, the way Boing "threw together" the 747; it wasn't exactly a
casual or quick process.

ITYM "a standard".

Your failure to perceive its utility does not diminish it. That's on
of the most useful features of REXX.


Your lack of familarity with it does not make it bad or unusual; it
appears in other languages.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT

Unsolicited bulk E-mail will be subject to legal action. I reserve
the right to publicly post or ridicule any abusive E-mail.

Reply to domain Patriot dot net user shmuel+news to contact me. Do
not reply to spamtrap@library.lspace.org
  Reply With Quote
7 28th February 04:03
jeff glatt
External User
 
Posts: 1
Default Call differences between rexx implementations


I'm sure it is... to people who use REXX as a batch language.

But there are other people who do not use REXX as so.
  Reply With Quote
8 28th February 04:04
ian
External User
 
Posts: 1
Default Call differences between rexx implementations


I actually 'got' that it was not the ANSI stanard. Owning both the first
and second editions of Colishaw's book, it was plainly the case when I
finally examined in detail what it said. I thought my use of the word
'intuitively' was a tip-off that I was speaking of how a standard might
be improved to make the language more consistent, without, I thought,
doing any damage to it.

What frustrated me no end was having regina work one way at home, and
another way at work, and having all 3 interpreters do different things
in various situations. The latest Regina, for example, will NOT
consistently pass commands to 'Windows DOS' in Win 2K. That one I had to
resolve by moving the command to a batch file. It also crashes under
cir***stances that do not phase either IBM nor reginald rexx.

When I have time to clearly re-create it, I'll post an issue with a
string that I had yesterday that none of the interpreters liked, and I'd
like to know why.

ian
  Reply With Quote
9 28th February 04:04
florian_große-coosmann
External User
 
Posts: 1
Default Call differences between rexx implementations


ian schrieb:


Oops, that's not nice.


We checked nearly every combination last December. The main problem
with Windows 2K is the braindamaged behaviour with programs that switch
between the environment (16 bit vs 32 bit). This is fixed in XP, but
2K is buggy.

Because of ANSI's redirection feature that we want to support we have
had to create some synchroneous communication pipes. These won't work
in all cases when switching between protected and real mode programs.

In short this means:
a) Always use a 32-bit-interpreter (CMD.EXE) instead of
a 16-bit-interpreter (COMMAND.COM) for all things if you can choose.
The interpreter is selected by the COMSPEC environment variable.
b) Try choosing a different ADDRESS environment. The default is
ADDRESS SYSTEM, but sometimes ADDRESS PATH may give a better
result because no interpreter is used at all. The newest Regina
changed the semantics of CMD and COMMAND to point to PATH.
The name of the ADDRESS environment isn't standardized. This
makes things more difficult to manage various REXX interpreters,
sorry.
c) If you don't use Regina in a GUI environment and you start a
16-bit-GUI program you can try "ADDRESS SYSTEM 'START' gui16.exe"


This will be interesting.

Cheers, Florian
  Reply With Quote
10 9th March 01:49
shmuel (seymour j.) metz
External User
 
Posts: 1
Default Call differences between rexx implementations


In <vjn0qvk41hkl05omi1bhdu788f0okhv4f7@4ax.com>, on 10/29/2003
at 07:44 PM, Jeff Glatt <jglatt@spamgone-borg.com> said:

Among others.

And it's very useful there as well. What looks like a command to one
person looks like a service to another.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT

Unsolicited bulk E-mail will be subject to legal action. I reserve
the right to publicly post or ridicule any abusive E-mail.

Reply to domain Patriot dot net user shmuel+news to contact me. Do
not reply to spamtrap@library.lspace.org
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666