Browse thread
Value shadowing
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Allsopp <dra-news@m...> |
| Subject: | RE: [Caml-list] Value shadowing |
> On Wed, Aug 13, 2008 at 09:54:36AM +0100, David Allsopp wrote: > > Suppose I have this piece of code: > > > > let foo xs = > > match xs with > > x::xs -> if x > > then xs (* Return the tail of the list *) > > else xs (* Return the entire list *) > > | [] -> raise Exit > > I'd find it very counter-intuitive if OCaml behaved like this, and > annoying if it gave a warning. Just name the variables to be > different! You seem to have missed my point that I wrote the above *in error* so "Just name the variables to be different!" is a clairvoyant response in this case... I'm aware that that's what has to change :o) That said, I do see your point that my proposed warning would mean that you could never match a list tail with the same name as the whole list - a definite weakness of my suggestion that I hadn't spotted before. Personally, I'd be happy to live with always using two names in this context - but perhaps this should therefore be the job of a home-grown postprocessor on .annot files, rather than a compiler feature request? David