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
Efficency of varient types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-26 (09:29)
From: Nicolas Cannasse <ncannasse@m...>
Subject: Re: [Caml-list] Efficency of varient types
Brian Hurt wrote:
> On Sat, 26 Nov 2005, Nicolas Cannasse wrote:
>> If you have a tagged variant where all constructors have a parameter, 
>> you can use Obj module to unbox the Int variant but the code is a lot 
>> less readable.
> As a general rule, unless you work at INRIA, you should never, ever use 
> the Obj module.  Not only will the code be signifigantly less readable, 
> it'll also be signifigantly more error prone, especially obscure, hard 
> to debug unless you are intimately familiar with the inners of the 
> garbage collector, segfault you program at random times, boy doesn't 
> this feel like C++ bugs.
> Brian

Still, you have sometimes to write C libraries, even if they can 
compromise the safety of the program. Using Obj in a OCaml library with 
an abstract interface in order to get additional optimizations can be 
useful, but only if you know what you're doing.

The original author was talking about some code generator that was 
targeting OCaml so I guess in that case especialy using Obj makes sense.