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 TAA04594; Thu, 9 Jan 2003 19:28:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA04616 for ; Thu, 9 Jan 2003 19:27:59 +0100 (MET) Received: from grace.speakeasy.org (grace.speakeasy.org [216.254.0.2]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id h09IRwr20515 for ; Thu, 9 Jan 2003 19:27:58 +0100 (MET) Received: (qmail 2068 invoked by uid 36130); 9 Jan 2003 18:27:57 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 9 Jan 2003 18:27:57 -0000 Date: Thu, 9 Jan 2003 10:27:57 -0800 (PST) From: brogoff@speakeasy.net To: "A. Ozmen" cc: "caml-list@inria.fr" Subject: Re: [Caml-list] record declaration, SML In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, You've noticed that OCaml records aren't like SML records. Here are a few places where they differ. You can't have anonymous records in OCaml, so in the case of a datatype declaration like yours you need something like type t = C of t_record and t_record = { f : int } If you hide the record definition, then you can't match on it, but I imagine you know that already. In the case of anonymous records as function arguments, you could try labels. In the case of records in a module sharing field names, well, you can't do that either, so you'll need to use classes or find some way to disambiguate the fields. This is one of those annoyances of Caml (like the lack of overloading :) that you just need to get used to. SML is a bit better here IMO, but still not ideal; I think that there was an SML variant (SML#) that was appealing but it looks like that idea isn't going anywhere. There are a few other conveniences in SML record handling too, like the ... notation, that don't exist in OCaml. Oh yeah, also be careful initializing records with stateful functions, because you may be surprised at the order of evaluation. -- Brian On Thu, 9 Jan 2003, A. Ozmen wrote: > Hi, > > What's best translation of the following SML type? > datatype t = C of { f : int } > > I have to define extra record types, I guess. Then, not including these > types in interface (.mli) files? Is this the right approach? > > Thanks. > __________________________________________________________ > Get your Private, Free Email from HTTP://www.DmailMan.Com > ------------------- > 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 > ------------------- 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