RE: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Paul Marquess

 
> > Is that the "soon to be released" E5?
> 
> No, that's the "to be released today" E5.
> 
> ;-)

Yy!!



Re: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Simon Cozens

[EMAIL PROTECTED] (Paul Marquess) writes:
> Is that the "soon to be released" E5?

Sometime today, all being well.

-- 
 I often think I'd get better throughput yelling at the modem.



Re: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Damian Conway

Paul Marquess wrote:

> Is that the "soon to be released" E5?

No, that's the "to be released today" E5.

;-)

Damian




Re: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Damian Conway

Simon Cozens wrote:

> While I'm messing about with REs, is it specified how :any and hypotheticals
> interoperate?
> 
>"ab" =~ rx:any / $match := (\w) /;
>print $match;
> 
> Can that be undefined behaviour? Please? :)

I don't think so.

It would probably result in $0 containing an array of match objects,
one for each possible match. Each of those second tier match
objects would then have a 'match' key in its hash attribute.

Hence, to see the individual hypotheticals one might write:

for @$0 -> $possible_match {
print $possible_match{match}, "\n";
}


A more intriguing possibility is that the top-level match object ($0 itself)
would *also* have a 'match' key...whose value contained a superposition of all
the possible hypotheticals. So you could also just write:

print egs( $0{match} _ "\n" );


Bwah-ha-ha-ha-hah!!

Damian






RE: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Paul Marquess


> The behaviour is explained quite well in E5 I think.

Is that the "soon to be released" E5?

Paul



Re: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Simon Cozens

[EMAIL PROTECTED] (Damian Conway) writes:
> It's not an exception, but you could certainly *implement* it that way.

I would argue that it is in some sense, if not an Official Perl 6 Exception,
since it jumps out of several levels of a match. But yeah, I'm probably
just looking at this from an implementor's viewpoint.

> It gives up tracktracking the immediately preceding atom.
> The behaviour is explained quite well in E5 I think.

Aha! Got it, thank you.

While I'm messing about with REs, is it specified how :any and hypotheticals
interoperate?

   "ab" =~ rx:any / $match := (\w) /;
   print $match;

Can that be undefined behaviour? Please? :)

-- 
DEC diagnostics would run on a dead whale.
-- Mel Ferentz



Re: :, ::, :::, and :::: in P6REs

2002-08-22 Thread Damian Conway

> I think I can distinguish :: from ::: - :: fails the current branch point,
> whereas ::: fails the entire rule. 

Correct.

> I think I can distinguish between ::: and ; the implementation
> is a bit tricky, because ::: fails the current match - easy enough -
> whereas  has to specify to all upper-level matches that they
> failed too. Is it reasonable for failing a  to be an exception?

It's not an exception, but you could certainly *implement* it that way.


> I don't think I can distinguish between : and ::. Essentially, how many
> nodes does each commit to? I would expect the following
> 
> [ a+ : b | c+ : d | e+ : f ]
> 
> to do precisely the same as 
> 
> [ a+ :: b | c+ :: d | e+ :: f ]

It doesn't. The first says:

[ # Non-capturingly...
a+#Match 1+ a's
: #And never backtrack to match fewer a's
b #Then match a b
| # Or if that failed...
c+#Match 1+ c's
: #And never backtrack to match fewer c's
d #Then match a d
| # Or if that failed...
e+#Match 1+ e's
: #And never backtrack to match fewer e's
f #Then match an
]

whereas the second says:

[ # Non-capturingly...
a+#Match 1+ a's
::#And if you ever have to backtrack,
   #  then immediately fail the entire surrounding group
b #Then match a b
| # Or if that failed...
c+#Match 1+ c's
::#And if you ever have to backtrack,
   #  then immediately fail the entire surrounding group
d #Then match a d
| # Or if that failed...
e+#Match 1+ e's
 ::#And if you ever have to backtrack,
   #  then immediately fail the entire surrounding group
f #Then match an f
]

So a single colon has the same effect as the Perl 5 (?>...) metasyntax.


> I don't see why Larry describes one as "if-then", but not the other.
> Basically, I don't think I'm sure what : "gives up".

It gives up tracktracking the immediately preceding atom.
The behaviour is explained quite well in E5 I think.

Damian




:, ::, :::, and :::: in P6REs

2002-08-22 Thread Simon Cozens


I don't usually have problems with commitment...

I think I can distinguish :: from ::: - :: fails the current branch point,
whereas ::: fails the entire rule. I can do ::: trivially.

I think I can distinguish between ::: and ; the implementation
is a bit tricky, because ::: fails the current match - easy enough -
whereas  has to specify to all upper-level matches that they
failed too. Is it reasonable for failing a  to be an exception?
This would save passing "hard" and "soft" failure codes around. 

 is just  with a couple of knobs on.

I don't think I can distinguish between : and ::. Essentially, how many
nodes does each commit to? I would expect the following

[ a+ : b | c+ : d | e+ : f ]

to do precisely the same as 

[ a+ :: b | c+ :: d | e+ :: f ]

I don't see why Larry describes one as "if-then", but not the other.
Basically, I don't think I'm sure what : "gives up".

(Apologies if this doesn't sound as lucid as normal, it's 5:31am and I
have been hacking too long.)

-- 
Um. There is no David conspiracy. Definitely not. No Kate conspiracy either.
No. No, there is definitely not any sort of David conspiracy, and we are
definitely *not* in league with the Kate conspiracy. Who doesn't exist. And
nor does the David conspiracy. No. No conspiracies here. - Thorfinn, ASR