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: Michael Vanier <mvanier@c...>
Subject: Re: [Caml-list] extensible records again

> From: skaller <skaller@users.sourceforge.net>
> Date: 22 Mar 2004 04:06:18 +1100
> 
> 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)
> ....
> 

Is the code for Vyper still available?

Also, is there really any significant speed difference between polymorphic
variants and regular variants?  How would this compare to using exceptions
as an extensible variant type?

Mike


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