From: martinc@grover.cs.unc.edu (Charles R. Martin)
Newsgroups: comp.lang.rexx
Subject: Re: Blanks, REXX, and portability...
Date: 7 Sep 92 15:07:59 GMT
Organization: UNC Department of Computer Science
In-reply-to: GOMBERG@UCSFVM.BITNET's message of 7 Sep 92 05:32:37 GMT

In article <REXXLIST%92090701365930@UGA.CC.UGA.EDU> GOMBERG@UCSFVM.BITNET (Dave Gomberg) writes:

   Well, the Unix folks have rather dug themselves a hole on that one,
   haven't they, Charlie.  It's not just a question of parse, what about
   substr, or left/right.  They will have the same problem.  I guess we
   could say that just because c=a||b doesn't mean expand(c)=expand(a)||
   expand(b).  But we knew that already.  And your parse example is just
   this problem in another guise.  In fact, the Unix folks have a worse
   problem.  You can have c=a||b, but pos(a,c)=0!  Wow!  I don't think
   I want that in MY os.  But there is no accounting for taste!   I would
   really like Anders (I assume the first letter is in fact capitalized)
   and other Unix types to say if they can stand it that:

       c=a||b;  say pos(a,c)

   would say 0?  It is not what I mean by REXX.  Sorry this rambles so.
   Dave

I guess it's my turn to be confused; this reads as if we've gone back to
the idea that pos should "hit" on both tab and blank as a special case.

Just to jump on my formal-methods high horse for a second, this is what
really comes of trying to do programming-language semantics without a
mathematical basis: we keep hacking back and forth on what we mean by so
and so.  (Don't take this as a personal criticism, by the way -- this is
a standard screwup in programming langauges, in my opinion.  See e.g.
the Ada specification.)

So here's an idea: I'll introduce an idea of regular expression for Rexx
and describe what *I* think this all means, and maybe that'll clear
things up.  (By the way, this isn't a serious proposal for rexx syntaxx
here, just a notation for discussion.)

Let's use something like emacs regex expressions, since they can be
typed easily; Regular expressions are contained within <>'s, and use
backslash as an escape character.  So,

<a> 	is a regular expression matching exactly one 'a'
<a*>	is a reg exp matching 0 or more 'a's
<a<a*>>	is a reg exp matching 1 or more 'a's (which is sufficiently
	useful that it's abbreviated using the + operator, i.e. <a+>)
<.>	matches any one character
<.+>	matches one or more of any character
<\.>	matches only '.' itself.
<a|b>	matches either 'a' or 'b'
<^a>	matches anything except 'a'
<^<a|b>>	matches anything except 'a' or 'b'

Let's also alias certain characters with escapes, e.g., \t is notation
for the TAB character in whatever coding set is in use.

Now, POS is a simple regular expression matcher that doesn't allow any
of the regular set operations; that is, the search string is just a
regular expression with no *,+,|,^, or . operators.  It's clear then
that if we think of POS("a b", string) as POS(<a b>, string) we have
exactly the expected behavior as I think we've agreed.  That is, since
<a b> matches only the substring "a<space>b" it ignores the substring
"a<tab>b".

I think the contention is that

parse arg a b c

ought to be a synonym for 

parse upper arg with a<<\b|\t>+>b<<\b|\t>+>c

Now if we had that, I don't see immediately what the need for parse
expand would be; in fact, given that the simple identity doesn't hold
after parse expand, maybe the whole idea is broken.  Ah, well, such is
the risk of informal language definition.  I suppose it must be left in
at this late date.

But the idea of embedded general regular expressions in parse is such a
nice one, and seems like such a natural extension to the existing parse,
that I think it ought to be seriously considered.
--
Charles R. Martin/(Charlie)/martinc@cs.unc.edu/(ne crm@cs.duke.edu) 
O/Dept. of Computer Science/CB #3175 UNC-CH/Chapel Hill, NC 27599-3175
H/3611 University Dr #13M/Durham, NC 27707/(919) 419 1754
----------------------------------------------------------------------
"I am he who walks the States with a barb'd tongue, questioning every
one I meet,/Who are you that wanted only to be told what you knew
before?/ Who are you that wanted only a book to join you in your
nonsense?"  _Leaves of Grass_ xxiii.4.
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU