Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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.


Sven Luther

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: