[cduce-users] default match policy not working in sequences

Giuseppe Castagna Giuseppe.Castagna at ens.fr
Wed Nov 3 23:53:26 CET 2004


Matthias Radestock wrote:
> Giuseppe Castagna wrote:
> 
>> We could write
>>
>> (x:=1) for the non consuming pattern
>> (x+=1) for the consuming one
>> and define (x?=1) as a shorthand for (x+=1)|(x:=1)
> 
> 
> I actually had the same idea. However, I believe Alan's /p syntax is 
> only  meant to be valid inside a regexp - for a good reason: it is 
> unclear what it means to "not consume anything" outside the context of 
> regexp pattern,

I intended the pattern (x-=1) to be used only in regular expressions. 
This is why I prefer my second proposal to my first one, as it preserves 
the semantics of (x:=1).



 > Btw, note that there would be no reason to define a syntax for a
 > consuming default pattern (your += above), other than convenience, since
 > (x+=c) is equivalent to _ & (x:=c).
 >

Yes, and this was the reason why, I think, at the end we chose the non 
consuming semantics. My point, if you want, is that this may not be a 
good choice since it makes the same pattern (x:=c) have two different 
meanings according to whether it is used in a regular expression or not. 
So the idea is to keep the old semantics and add extra syntax (x-=c) 
*just for regular expression* for the special non-consuming case.

Beppe





More information about the Cduce-users mailing list