Paul, this is getting complicated. I can't tell whether you mistook my
meaning, or understood it just fine and your answer is relevant even though
it took a twist I didn't expect. Let me try again, and we'll see: When I
inserted parens in my examples, last time, I didn't mean them literally. In
fact I started out deliberately to use square brackets, to make it clear
that I was talking about precedence of handling rather than actual parens in
the REXX code. Let's express it this way and see whether your reply changes
(and if it doesn't maybe I'll understand it better the second time around:
nstem.count=nstem.count+1 /* example */
If REXX were to allow expressions to be embedded in stem tokens, how could
the interpreter (or I, for that matter) know what that statement meant?
Let's say count=3, nstem.3=100 and nstem.4=200; as REXX is defined now this
statement means
v=nstem.count /* v=nstem.3, that is, v=100 */
v=v+1 /* v=101 */
nstem.count=v /* nstem.3=101 */
But if expressions are allowed in stem tokens, it might also mean this:
v=count+1 /* v=4 */
nstem.count=nstem.v /* nstem.3 = nstem.4, ie nstem.3=200 */
...or, if you want to get really ugly:
v=count+1 /* v=4 */
if count=nstem.v, /* if 3=nstem.4, ie if 3=200 */
then v=1
else v=0
nstem.v /* execute the command in nstem.0 or nstem.1 */
Yeah, I understand better now; I should not have used parens. In the last
example, count+1 is evaluated first so the statement becomes
"nstem.count=nstem.4", or nstem.count=200. Then "count=200" is evaluated,
ie "3=200", which is false or 0. So the command in nstem.0 is executed.
It's a silly example, of course. My point is just that if we're to allow
expressions inside stem tokens, doesn't that open the door to an impossible
situation?
/* My aunt has rather selfishly suspended her production of chocolate cake
because of the whole "broken hip" thing, leaving me to try to find a
worthwhile substitute....I purchased a box with a picture of a cake on it,
but inside were all these so-called "ingredients" that, once I'd mixed them
and baked them and put out the flames, tasted suspiciously like one of my
mother's chocolate hockey pucks. -Bruce Cameron */
-----Original Message-----
From: Paul Gilmartin
Sent: Saturday, January 19, 2013 11:25
The problem arises _only_ because function names are allowed to
end with a period. Your example is a function call:
nstem.(count=nstem.(count+1)) /* ok, I said it was ugly */
to, for example:
nstem.:
say arg( 1 )
return
if the ".(" sequence were always taken as introducing an expression
used as a compound tail, this restriction could vanish. Or a new
symbol could be introduced to the syntax. This is hardly an unsolvable
problem. Other languages such as C and awk both accept and handle
intuitively such as:
nstem[ count == nstem[ count + 1 ] ]
the nightmare of EBCDIC code pages makes the Rexx developers intensly
averse to extending the character set in such fashion.
--- On Jan 19, 2013, at 09:06, Bob Bridges wrote:
> Consider this common example:
>
> nstem.count=nstem.count+1
>
> If REXX were to allow expressions to be embedded in stem tokens, how could
> the interpreter (or I, for that matter) know what that statement meant?
>
> nstem.count=(nstem.count)+1 /* the only possible meaning currently */
> nstem.count=nstem.(count+1) /* an alternate meaning */
>
> ...or, if you want to get really ugly:
>
> nstem.(count=nstem.(count+1)) /* ok, I said it was ugly */
>
> If you argue that simple string literals are an easy enough exception, I'm
> tempted to agree. But then, I've never tried to write a full language
> interpreter; maybe if I had, I'd know that even this exception causes
> insoluable problems.