From: doligez@pa.dec.com
Message-Id: <199903092157.AA14156@six.pa.dec.com>
To: Andrew Martin <amartin@ibmoto.com>
Subject: Re: CamlIDL - stub code generator and COM binding for OCaml
In-Reply-To: Message of Fri, 05 Mar 1999 14:46:35 -0600
from Andrew Martin <amartin@ibmoto.com>
Date: Tue, 09 Mar 1999 13:57:11 -0800
>From: Andrew Martin <amartin@ibmoto.com>
>How can one deal with two struct types whose members have the same names.
>In Ocaml, for example:
>
>type foo = {a:int; b:int}
>type goo ={a:char; b:char}
>
>How can I now create an object of type foo? It would be nice if I could write
>let x = ({a=4; b=5;}:foo) or
>let x = {foo.a=4; foo.b=4} or even
>let (x:foo) = {a=4; b=4}
You can get (almost) your second solution simply by declaring:
type foo = {foo_a : int; foo_b : int};;
type goo = {goo_a : char; goo_b : char};;
Then you can write:
let x = {foo_a = 4; foo_b = 4}
-- Damien
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:20 MET