Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] How can I simulate dynamic types in OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven Luther <luther@d...>
Subject: Re: [Caml-list] How can I simulate dynamic types in OCaml?
On Fri, Apr 04, 2003 at 03:58:42AM -0800, sergey dyshel wrote:
> Hi
> 
> I like static type-checking in OCaml but sometimes I
> need to implement some dynamic stuff (like a list of
> values of different types). Is there a way to
> do it in OCaml or at least simulate this?

Use a list of variants ?

type element = A of a | B of b | C of c | D of d | ...

type liste = element list 

You have to check the appropriate variant each time (or most time) you
use it, but after all, you wanted dynamic type checking.

Friendly,

Sven Luther

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