Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] extensible records again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] extensible records again
On Mon, 2004-03-22 at 03:10, Oleg Trott wrote:
> Michael Vanier wrote:
> 
>  In fact, in your case, I believe it's more convenient 
> not to create an artificial distinction between the "core types" and 
> "other types": suppose someone extended your language with "files", and 
> you later decide to add "file" to your "core types". You'll have to 
> redefine "data" and refactor a lot of your base code to do it, unless 
> you just use polymorphic variants, as suggested (in which case there is 
> no special distinction between "core types" and "other types").

However there IS a reason for making the distinction sometimes,
namely performance.

My Vyper interpreter (a Python interpreter written in Ocaml)
used a type like

type PyObject = Int of int | Float of float |
String of string | PyClass of pyclass

which deliberately distinguished simple types
so that a fast match could be used to perform
common calculations:

match o1, o2 with
| Int i, Int j -> Int (i + j)
....

-- 
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