Browse thread
Same label in different types, how do people solve this?
[
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: | Pierre Weis <weis@p...> |
| Subject: | Re: Same label in different types, how do people solve this? |
> Mattias Waldau wrote :
> > In Ocaml, you cannot have the same label in different types, see the
> example
> > below where point_2d hides point_3d.
>
> Troublemaker :-). There is a thread on this topic on comp.lang.functional.
> Please, FAQ maintainer, this is very definitely FAQ material!
Feel free to propose an entry for the FAQ (in english and french
please): I would be glad to add it.
[...]
> Pierre Weis wrote
> > I would suggest another syntactic notation to specify the type to
> > which a label belongs: label@@type.
> >
> > {x@@p2d = 0; y = 5}
> > r.x@@p2d
>
> I don't want to start a syntax war, but I think Ocaml is already suffering
> a bit from too much added syntax and this doesn't look good to me. Jacques'
> reuse of ":" (I know, it applies to the whole record and not a label) is
> easier on my eyes, which already associate ":" with typing.
>
> -- Brian
The notation I suggested is simpler to implement and specify: there is
nothing new in type constraints propagation and label overloaing
resolution strategy: just a notation to specify the type to which a
label or constructor belongs to in the same spirit as usual
qualification of names in the module system.
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/