Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] Question
[...]
>  I was expecting "when" to be right distributive over "|". I find
> OCaml's behaviour not very intuitive in such a situation.
[...]

The when construct introduces a guard to a pattern matching
clause. This means that a when construct is global to the entire
pattern of the clause it appears in; it means in particular that no
when construct can be nested into a pattern and the question of its
distributivity wrt any other construct is pointless.

>  Is there a good reason for this?

Yes: simplicity, complexity invariants preservation for runtime
pattern analysis decisions even in the presence of when clauses,
easier understanding of the compiler warnings, simplicity and
well-definedness semantics (in particular the desired invariance wrt
the order of evaluation).

>  Cheers,
> 
>  Sébastien.

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners