From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA11378; Fri, 10 Jan 2003 00:11:48 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA11364 for ; Fri, 10 Jan 2003 00:11:47 +0100 (MET) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (host97-68.pool80116.interbusiness.it [80.116.68.97]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h09NBk500487 for ; Fri, 10 Jan 2003 00:11:46 +0100 (MET) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 51A0D27249 for ; Fri, 10 Jan 2003 00:14:17 +0100 (CET) Message-ID: <3E1E0249.6050102@baretta.com> Date: Fri, 10 Jan 2003 00:14:17 +0100 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Ocaml Subject: Re: [Caml-list] record declaration, SML References: <20030109234207.B19061@verdot.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Daniel de Rauglaudre wrote: > Hi, > > >>What's best translation of the following SML type? >>datatype t = C of { f : int } > > > A solution is: > type t = C of < f : int > Interesting solution. However, Ocaml does not support defining objects on the fly. The following > let c = new object method f = 1 end in C c is not valid Ocaml. So, in order to define just one value one needs to define an entire class as in the following example. class f_one = object method f = 1 end let res = C (new f_one) BTW, why is something like the above not in the language? It seems only natural to have such a feature since an analogous construct exists for structs. let module C = struct let f = 1 end in C.f Alex ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners