Version française
Home     About     Download     Resources     Contact us    
Browse thread
Patterns that evaluate
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] Patterns that evaluate
Gerd Stolpmann wrote:
> Am Mittwoch, den 14.02.2007, 14:11 -0500 schrieb Jacques Carette:
>> Gerd Stolpmann wrote:
>>> Before discussing syntax it is more important to
>>> define the semantics of such patterns. I mean we have already three
>>> predefined kinds of equality in O'Caml:
>>>
>>> - ( == )
>>> - ( = )
>>> - (fun x y -> compare x y = 0)
>>>
>>> I admit I do not prefer any one of them. So which equality should be
>>> used to test whether the variable is equal to the matched part of the
>>> value?
>>>   
>> I would definitely favour structural equality, since that meshes well 
>> with pattern-matching's semantics.  Anything else would seem hard to 
>> justify, but that's just my opinion.
> 
> It is easy to have another opinion (and that's the basic problem). There
> is a good reason to prefer physical equality: pattern matching
> decomposes physically anyway, so this equality looks more natural. On
> the other hand, the existing string matching (match s with "literal")
> compares string contents. 
> 
> It is already a mess.
> 
> Gerd

If I have to, I think I can satisfy both structural and physical 
equality with different tokens:

If you want:
* structural equality, use |= to prefix the pattern case
* physical equality, use |== to prefix the pattern case
* something else, use | and when to specify whatever explicit guard you 
want.

Does this satisfy all parties?

E.