Browse thread
different records, same field name?
-
mfmorss@a...
- Jon Harrop
- Basile STARYNKEVITCH
- DooMeeR
[
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: | Basile STARYNKEVITCH <basile@s...> |
| Subject: | Re: [Caml-list] different records, same field name? |
mfmorss@aep.com wrote:
>
> In any case, is it possible to define and use different types of records,
> which nevertheless share some field names? I have had difficulty doing
> this in the toplevel.
It is not possible, for a simple reason:
Suppose you have two record type tr1 & tr2 sharing a common field name f
type tr1 = { f : int; f1 : string }
type tr2 = { f2 : float; f: int }
Then the compiler won't be able to infer the type of function ff
retrieving this field f
let ff x = x.f
So the requirement that each field name is different is the price to pay
to have type inference.
Regards
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***