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 C51BEBB91 for ; Sat, 23 Jul 2005 20:27:11 +0200 (CEST) Received: from postfix3-1.free.fr (postfix3-1.free.fr [213.228.0.44]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6NIRBuc012546 for ; Sat, 23 Jul 2005 20:27:11 +0200 Received: from quatre.invalid (vol75-1-81-57-79-249.fbx.proxad.net [81.57.79.249]) by postfix3-1.free.fr (Postfix) with ESMTP id 37B111734C0; Sat, 23 Jul 2005 20:27:11 +0200 (CEST) Received: from berke by quatre.invalid with local (Exim 4.50) id 1DwOiL-0001I7-Kw; Sat, 23 Jul 2005 20:27:09 +0200 Date: Sat, 23 Jul 2005 20:27:09 +0200 From: Berke Durak To: Stephane Glondu Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? Message-ID: <20050723182709.GA4076@ara.zapto.org> References: <42E2393B.5030209@inria.fr> <20050723131626.GB11661@ara.zapto.org> <200507230936.47352.Stephane.Glondu@crans.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200507230936.47352.Stephane.Glondu@crans.org> User-Agent: Mutt/1.5.9i X-Miltered: at nez-perce with ID 42E28BFF.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 berke:01 durak:01 unspecified:01 type-safe:01 ocaml:01 recursive:01 mutable:01 mutable:01 rec:01 heap:01 ...: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 09:36:47AM -0700, Stephane Glondu wrote: > On Saturday 23 July 2005 06:16, Berke Durak wrote: > > 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... > > That seems to be dirty and would surely beak type safety. > > > This is clearly feasible for base types. > > possible for tuples, records and functions of base types. > > What do you mean? I mean that there could be a built-in, type-safe Ocaml function that would yield a valid, yet arbitrary value of any type. > > Recursive values could prove problematic : > > > > type stuff1 = { mutable a : stuff2 } > > and stuff2 = { mutable b : stuff1 } > > What's the problem here? You can always define a dummy value of a given > type: > > let rec dummy1 = { a = dummy2 } and dummy2 = { b = dummy1 } Yes of course, but you may need to compute a path in a type dependency graph. > > Would it be worth the fuss ? > > I think that a better design (which doesn't need such hacks) would be > worth. That was my point. You could cleanly initialize your heap with that "any" value. -- Berke Durak