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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id EC5ECBB81 for ; Sun, 24 Jul 2005 09:28:04 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6O7S4Vp031928 for ; Sun, 24 Jul 2005 09:28:04 +0200 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 JAA24865 for ; Sun, 24 Jul 2005 09:28:04 +0200 (MET DST) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6O7S3eE001243 for ; Sun, 24 Jul 2005 09:28:03 +0200 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id 32AC32BAB90 for ; Sun, 24 Jul 2005 09:27:59 +0200 (CEST) Message-ID: <42E342FE.6060408@barettadeit.com> Date: Sun, 24 Jul 2005 09:27:58 +0200 From: Alex Baretta User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] "Just say no!" campaign against Obj [was: How to do this properly with OCaml?] References: <42E2393B.5030209@inria.fr> In-Reply-To: <42E2393B.5030209@inria.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42E34304.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42E34303.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 ocaml:01 binary:01 heap:01 heap:01 recursion:01 ligth:01 recursion:01 variants:01 generations:01 compiler:01 annotations:01 type-safe:01 segfault: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.9 required=5.0 tests=FORGED_RCVD_HELO,PLING_QUERY autolearn=disabled version=3.0.3 Xavier Leroy wrote: >>I was constructing a binary heap of tuples the other day. After pondering >>these options, I just used Obj.magic 0 as the null value in the array. >>The heap was in a module, so nothing else could see the array, and I could >>prove that the code never accessed the null elements, so the use of >>Obj.magic seemed justified. > > > In other terms: > > " I was walking in the city the other day. I saw a syringe lying on > the sidewalk. I stuck the needle in my forearm. That was a classy > neighborhood, so the use of the syringe seemed justified. " Once upon a time I felt a desperate need for polymorphic recursion. At that time the INRIA gang was selling a new ligth drug whose effects are similar to polymorphic recursion. They called it "polymorphic records". Polymorphic records do not give addiction--unlike polymorphic variants, which are much more dangerous from this point of view--but when they are used to attain that euphoric state of mind given by polymorphic recursion, they must be injected in one's code with Obj.magic. Yes, i picked up the syringe and used it. Yes, I got ill with type-unsafety, but eventually careful medication made me recover. At the end, I must say experiencing polymorphic recursion was well worth the pain that came from using Obj.magic. Notwithstanding my experience, I agree with Xavier that is the social duty of us all to discourage the young generations to take Obj as a means to escape the conventional type system imposed upon them by society. We must convey the idea that the type system the elders have perpetuated since the time of the professor Church is for their own good! So, when confronted with Obj, guys, "Just say no!" Yet, I believe we must make some allowance for the need for polymorphic recursion. If the laws of the compiler allowed type annotations to substitute type-inference alone--not type-checking--for the sake of having type-safe polymorphic recursion, then, maybe, less young people would be deceived into taking the road of Obj, which inevitably leads to a segfault. ;) Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project