From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 938ADBB9C for ; Sat, 26 Nov 2005 10:29:51 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAQ9ToP1009047 for ; Sat, 26 Nov 2005 10:29:51 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA28062 for ; Sat, 26 Nov 2005 10:29:50 +0100 (MET) Received: from irma.motion-twin.com (irma.motiontwin.com [213.186.50.39]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAQ9To9A009041 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sat, 26 Nov 2005 10:29:50 +0100 Received: from [82.225.176.25] (helo=[192.168.0.1]) by irma.motion-twin.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.54) id 1EfwNP-0005oX-Hu; Sat, 26 Nov 2005 10:29:47 +0100 Message-ID: <43882D43.2040905@motion-twin.com> Date: Sat, 26 Nov 2005 10:39:15 +0100 From: Nicolas Cannasse User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Brian Hurt Cc: "Michael D. Adams" , caml-list@inria.fr Subject: Re: [Caml-list] Efficency of varient types References: <4387ACC9.2040107@motion-twin.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43882B0F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43882B0E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; cannasse:01 ncannasse:01 motion-twin:01 caml-list:01 cannasse:01 constructors:01 intimately:01 garbage:01 segfault:01 ocaml:01 ocaml:01 wrote:01 wrote:01 abstract:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 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. Nicolas