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 1D7BCBB91 for ; Sat, 23 Jul 2005 15:15:42 +0200 (CEST) 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 j6NDFfgW015760 for ; Sat, 23 Jul 2005 15:15:41 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12679 for ; Sat, 23 Jul 2005 15:15:41 +0200 (MET DST) Received: from postfix4-2.free.fr (postfix4-2.free.fr [213.228.0.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6NDFera022237; Sat, 23 Jul 2005 15:15:40 +0200 Received: from quatre.invalid (vol75-1-81-57-79-249.fbx.proxad.net [81.57.79.249]) by postfix4-2.free.fr (Postfix) with ESMTP id 7FA4C3231CD; Sat, 23 Jul 2005 15:15:40 +0200 (CEST) Received: from berke by quatre.invalid with local (Exim 4.50) id 1DwJre-00075W-J4; Sat, 23 Jul 2005 15:16:26 +0200 Date: Sat, 23 Jul 2005 15:16:26 +0200 From: Berke Durak To: Xavier Leroy Cc: Michael Alexander Hamburg , Thomas Fischbacher , caml-list@inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? Message-ID: <20050723131626.GB11661@ara.zapto.org> References: <42E2393B.5030209@inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42E2393B.5030209@inria.fr> User-Agent: Mutt/1.5.9i X-Miltered: at concorde with ID 42E242FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42E242FC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; berke:01 durak:01 caml-list:01 ocaml:01 binary:01 heap:01 heap:01 unspecified:01 recursive:01 mutable:01 mutable:01 berke:01 durak:01 sidewalk:98 needle:98 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 On Sat, Jul 23, 2005 at 02:34:03PM +0200, 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. " Quite a metaphor. However I was wondering how feasible it would be to have a "any : 'a" value, that would return an (unspecified) value of any given type... This is clearly feasible for base types. Hence it should also be possible for tuples, records and functions of base types. Recursive values could prove problematic : type stuff1 = { mutable a : stuff2 } and stuff2 = { mutable b : stuff1 } Would it be worth the fuss ? -- Berke Durak