RE: more match() problems

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 28 May 2003, at 18:14, Al Getz wrote:

> 
> 
> Mike Nelson wrote:
> > 
> > 
> > Derek Parnell wrote:
> > 
> > <snip>
> > >   match() LOOKS FOR SLICES - ALWAYS.
> > >   find() LOOKS FOR ELEMENTS - ALWAYS.
> > </snip>
> > 
> > This is entirely correct and is as it should be. I would further 
> > emphasize
> > that find() and match() only work at the top level.
> > 
> > Since match() always looks for slices, an atom as the first parameter is and
> > should be an error.  An empty sequence as the first parameter is also an
> > error--a return of 0 is preferable, as it would eliminate some special case
> > checking from code using match().
> > 
> > -- Mike Nelson
> > 
> > 
> Hi Mike,
> 
> I see your point.
> 
> I really only wanted match to be able to do
> i=match("",sequence) --rets 0
> 
> That's really all i wanted.

Me to, everything else would be gravey.

> In every case i think i've ever used match, ive used
> a variable sequence as the first argument, so i guess im
> not as worried about having it allow an atom as the first
> argument as some other people might be.

I always do something like this:

if atom(x) 
  then z = match({x},y)
  else z = match(x,y)
end if

or 

if sequence(x) 
  then z = match(x,y)
  else exit -- cannot use a goto eoroutine here!
end if

If i don't, sure as heck x will be "" eventually and the app will crash. Testing
for equal(x,"") or (length(x) = 0 ) repeatedly, over and over, ad nauseum 
helps(?) too.

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu