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 KAA21664; Fri, 10 Jan 2003 10:21:17 +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 KAA21827 for ; Fri, 10 Jan 2003 10:21:16 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0A9LCr16778; Fri, 10 Jan 2003 10:21:13 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA21874; Fri, 10 Jan 2003 10:21:12 +0100 (MET) Date: Fri, 10 Jan 2003 10:21:11 +0100 From: Xavier Leroy To: brogoff@speakeasy.net Cc: "A. Ozmen" , "caml-list@inria.fr" Subject: Re: [Caml-list] record declaration, SML Message-ID: <20030110102111.A21055@pauillac.inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from brogoff@speakeasy.net on Thu, Jan 09, 2003 at 10:27:57AM -0800 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > What's best translation of the following SML type? > > datatype t = C of { f : int } > 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. Sometimes, it's acceptable to just omit the record type: type t = C of int You lose the naming of the arguments of the constructor, but for small numbers of arguments (e.g. 1 or 2), this is often tolerable. > There are a few other conveniences in SML record handling too, like the ... > notation, that don't exist in OCaml. You mean, in pattern-matching over records? Caml offers the same functionality without the ... notation, e.g. type r = { x: int; y: int } match r with { x = 1 } -> ... Because records are declared in advance, there is no requirement that all record labels be mentioned in a pattern matching. - Xavier Leroy ------------------- 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