[comp.os.vms] Puzzles in TPU-land ...

BJH@V3.INFERENCE.COM (Brian Hagerty x 111) (04/07/88)

VAX TPU time!!!

According to the manual the following TPU code ...

        pat1 := 'bar' & '.';
        pat2 := 'foo' & pat1;
        range1 := search(pat2,forward);

... finds a match in "A rose by any other foo would smell as bar."
                                          -----------------------

First, why is there this bogus interpretation of pat2?
Wouldn't you think pat2 should match 'foobar.'?
I understand the mechanism as explained in the manual, but is this
intuitive, or really useful?  In the SNOBOL tradition, if we wanted to
match 'foo', followed by an arbitrary number of characters, followed
by 'bar', we would use the ARBNO primitive between 'foo' and 'bar'.

BUT, given that this is the way TPU works (ie, nested patterns begin
new searches, even if there are intervening characters) can you
explain to me the following paradox?  Where is the consistency?

This nested pattern example (very similar to the one above) ...

        pat1 := 'foo ' & 'bar';
        pat2 := 'please ' & pat1;
        range1 := search(pat2,forward);

... finds a match in "would somebody please pass the foo bar?"
                                     -----------------------
whereas ...

        pat1 := 'jelly';
        pat2 := 'please ' & pat1;
        range1 := search(pat2,forward);

... finds *NO* match in "would somebody please pass the jelly bar?"

It doesn't seem to work quite right when pat1 is a single term rather
than two concatenated terms.


- Brian Hagerty [sic]    (for those of you conditioned to two g's)
- Network Manager
- Inference Corporation
- Lost Angeles, CA

carl@CITHEX.CALTECH.EDU (Carl J Lydick) (04/12/88)

 > This nested pattern example (very similar to the one above) ...
 > 
 >         pat1 := 'foo ' & 'bar';
 >         pat2 := 'please ' & pat1;
 >         range1 := search(pat2,forward);
 > 
 > ... finds a match in "would somebody please pass the foo bar?"
 >                                      -----------------------
 > whereas ...
 > 
 >         pat1 := 'jelly';
 >         pat2 := 'please ' & pat1;
 >         range1 := search(pat2,forward);
 > 
 > ... finds *NO* match in "would somebody please pass the jelly bar?"
 > 
 > It doesn't seem to work quite right when pat1 is a single term rather
 > than two concatenated terms.

The problem is that in the second case, pat1 is a string and not a pattern.
The presence of the "&" operator in the first example forces tpu to make pat1
a pattern.