Browse thread
different records, same field name?
[
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: | 2008-03-03 (16:54) |
From: | Jon Harrop <jon@f...> |
Subject: | Re: [Caml-list] different records, same field name? |
On Monday 03 March 2008 16:51:57 mfmorss@aep.com wrote: > I have not used OCaml, just done some reading about it and toyed with the > toplevel to see if it might be a useful tool here. I have "Practical > OCaml," which unfortunately is a rather wretched reference. > > 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. Field names will shadow others so you define the record types in separate modules: module Vec2 = struct type t = {x: float; y: float} end module Vec3 = struct type t = {x: float; y: float; z: float} end { Vec2.x = 2.; y = 3. } -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e