Browse thread
Record field label locality
[
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: | Brighten Godfrey <pbg@c...> |
| Subject: | Record field label locality |
Hi,
Here's something that I've wondered about for years; maybe someone
here can enlighten me. One of the few major annoyances in OCaml code
style is that if I define a record in one module, say a Graph module:
type t = {
nodes : node_t array;
}
then when I use it in another module, say with a graph variable `g',
then I have to write `g.Graph.nodes' rather than `g.nodes'.
I can understand why a record field label has to be uniquely
identified. But can't the explicit naming of the Graph module
usually be avoided, since the compiler will know that `g' is a
`Graph.t'? For example if I write something like
let g : Graph.t = make_graph () in
g.nodes
it seems to me that on the second line, the type of `g' and hence the
meaning of `g.nodes' is unambiguous.
Thanks!
~Brighten Godfrey