From: mks@cbmvax.commodore.com (Michael Sinz)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: AREXX parsing madness  -- will it ever be fixed?
Date: 14 Oct 92 13:40:17 GMT
Reply-To: mks@cbmvax.commodore.com (Michael Sinz)
Organization: Commodore, West Chester, PA

dylan@cs.washington.edu (Dylan McNamee) writes:
>
>I recently completed my first AREXX macro, a paren matching program for
>QED.  It works now, although quite slowly.  I had a bear of a time getting
>it to pass AREXX, though, and for the goofiest reasons:
>
>"Everyone" knows an AREXX program has to have a comment as its first line...

This is also a defined part of the REXX language.

>The parentheses for a function call _have_ to abut the function name, as in:
>  a_function(an_arg)
>but
>  a_function (an_arg) croaks...and the error message isn't informative...

Yes, and the REXX syntax makes this not easy to know about.

>"end else do" on the same line also croaks, without an intelligible error
>message.

You need a ; after the end...  "end; else do"

>
>And so on.  I would think that since this is ostensibly the "replacement" for
>Amiga Basic, that CBM would be taking pains to make the language a bit more
>forgiving...but the above problems are absolutely inexcusable.  White space
>should be white space should be white space, and error messages should be
>at least _hints_ as to what the problem is.

The problem is that the AREXX syntax is not open for free changes as it
is part of the REXX language standard.  The syntax is rather simple but
yet complex.  For example, your function() vs function () is a problem
since in REXX the only way to know if something is a function is via this
method.  Why? well the loose syntax.  For example, you can do:

	name='Mike Sinz'
	feet=6
	inches=1
	Say 'Size in inches:' name (feet*12) + inches

So, now, is the above going to print "Size in inches: Mike Sinz 73"
or is it going to call the name() function with the argument of 72
and then add 1 to the result of that before displaying it?

In fact, you could even do:

	player = name (feet*12) + inches

This is supposed to make the player variable contain "Mike Sinz 73"

Now, as to the missing ; after the END...  Yes, that one is strange and
hopefully a better message can happen at some point.  The message I get
"Symbol mismatch" means that it did not find a valid END for the DO.  It is
hard to change this too much since END can be part of a differnt context
including part of a string constant that is not in quotes...  (I know this
is strange, but that is the language)

>To end this tirade with a question, though:  If AREXX lacks a function,
>is it reasonably efficient to write the function in "C", make it resident,
>and call it from AREXX?  I've found that functions written in AREXX, especially
>ones that iterate through strings character at a time, are painfully slow.

Well, depends.  You can write what is called a function library for ARexx.
Things like the rexxsupport.library and rexxmath.library and
rexxarplib.library are all such things.

Now, so to functions that deal with strings:  What are you trying to do
with the strings?  REXX (and ARexx) has *many* powerful string functions
that can deal with strings *very* fast.  Things like PARSE and TRANSLATE
can do amazing things with strings in almost no time.

/----------------------------------------------------------------------\
|      /// Michael Sinz  -  Senior Amiga Systems Engineer              |
|     ///                   Operating System Development Group         |
|    ///   BIX:  msinz      UUNET:  mks@cbmvax.commodore.com           |
|\\\///                     When people are free to do as they         |
| \XX/                      please, they usually imitate each other.   |
\----------------------------------------------------------------------/