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 RAA16899; Sun, 21 Mar 2004 17:55:55 +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 RAA15812 for ; Sun, 21 Mar 2004 17:55:54 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2LGtpHd002708 for ; Sun, 21 Mar 2004 17:55:53 +0100 Received: from [192.168.1.200] (ppp114-118.lns1.syd3.internode.on.net [150.101.114.118]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i2LGthwn065693; Mon, 22 Mar 2004 03:25:47 +1030 (CST) Subject: Re: [Caml-list] extensible records again From: skaller Reply-To: skaller@users.sourceforge.net To: Michael Vanier Cc: caml-list In-Reply-To: <20040321062143.BE7D29BBA2@orchestra.cs.caltech.edu> References: <20040321062143.BE7D29BBA2@orchestra.cs.caltech.edu> Content-Type: text/plain Message-Id: <1079888437.3165.6.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 22 Mar 2004 04:00:38 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 extensible:01 sourceforge:01 2004:99 vanier:01 floats:01 mli:01 9660:01 glebe:01 bool:01 ints:01 bindings:01 ocaml:01 irrelevant:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 283 On Sun, 2004-03-21 at 17:21, Michael Vanier wrote: > I've written a dynamically-typed language in ocaml, and I want to be able to > add new types to the language without having to add new primitive types to > the system. See Felix. The core system has NO primitive types, not even bool: all primitive types are added by the user (as bindings to C types). > > Now I want to add a type for (say) files. I don't want this to be a type > at the same level as ints or floats, because I want users to be able to add > their own types to the language without hacking the core type definition. > I can do this as follows: > > (* types.mli *) > type data = > Int of int > | Float of float > | ... > | Extension of exn You can just use: | Extension of string * address where address is a machine address of some binary data. What it is is completely irrelevant, since the operations on user defined primitive data type can only be specified in one way: by providing C functions which manipulate that type. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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