Label Names Space - philosophy or implementation?

John Gerard Malecki (johnm@vlibs.com)
Mon, 22 Jul 1996 17:40:16 -0700 (PDT)

Date: Mon, 22 Jul 1996 17:40:16 -0700 (PDT)
Message-Id: <199607230040.RAA11401@owl.vlibs.com>
From: John Gerard Malecki <johnm@vlibs.com>
To: caml-list@pauillac.inria.fr
Subject: Label Names Space - philosophy or implementation?

A co-worker has (vehemently) pointed out to me that record label names
cannot be shared. For example, the following fails

type foo = { name : string; x : int }
let a = { name = "foo"; x = 1 }

type bar = { name : string; y : float }
let b = { name = "bar"; y = 9. }

let a' = { name = "foo"; x = 2 }

With an error message on the last line that "The label x belongs to
the type foo but is here mixed with labels of type bar". This annoys
my co-worker to no end. He would like many of his records to have a
field with a standardized label. This makes it easier for him to
write printers for his data-structure. Does anyone have a
recommendation to make to him?

Until this morning I would have guessed that the type of a record was
not resolved until all of the labels were examined. As I re-read the
caml-light and ocaml manuals I see that this is not true.

Are there good reasons for this "restriction"? I can see how this
this might be considered a good software practice. Maybe, due to
pattern matching, it is not possible to have shared labels.

Any comments?