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: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] Patterns that evaluate
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
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------