From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA05698; Fri, 15 Jun 2001 18:07:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA18542 for ; Fri, 15 Jun 2001 18:07:08 +0200 (MET DST) Received: from mrwall.kal.com (mrwall.kal.com [194.193.14.236]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f5FG77529875; Fri, 15 Jun 2001 18:07:07 +0200 (MET DST) Received: from mrwall.kal.com [194.193.14.236] (HELO localhost) by mrwall.kal.com (AltaVista Mail V2.0J/2.0J BL25J listener) id 0000_0045_3b2a_335d_e545; Fri, 15 Jun 2001 17:10:05 +0100 Subject: RE: [Caml-list] let mutable (was OCaml Speed for Block Convolutions) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Fri, 15 Jun 2001 17:05:08 +0100 content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 Message-ID: <8E31D6933A2FE64F8AE3CC1381EEDCE706EF73@NT.kal.com> Thread-Topic: [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Thread-Index: AcDwQPQ3F5UO76IfTTKOAZ8Yx4xcSQFAikMgABxqdpA= From: "Dave Berry" To: "Don Syme" , "Pierre Weis" , "Jacques Garrigue" Cc: Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I once advocated a "const" datatype for SML. The const constructor would create unique immutable values that could be compared for pointer equality, satisfying Don's first use of refs. (It's possible I included these in the Edinburgh SML Library -- I don't recall after all these years). But this idea never caught on. A similar idea is to define: type 'a pointer =3D 'a option ref fun null (ref NONE) =3D true | null _ =3D false fun ::=3D (p, v) =3D p :=3D SOME v Dave. -----Original Message----- From: Don Syme [mailto:dsyme@microsoft.com] Sent: 15 June 2001 04:20 [ To expand on why "mutable" fields are, IMHO, so much better... In Standard ML "refs" get used in data structures for four main purposes:=20 - to get values that can be compared by pointer equality;=20 - to ensure sharing of an allocation cell;=20 - to allow "regular" mutation;=20 - to cope with initializing recursive data structures using "ref option". =20 Because of these multiple uses I honestly used to get "ref" type constructors nested two or three deep (when designing some pointer-chasing graph structures)!! =20 I was never able to get this code right until I switched to Caml, precisely because my structures became simpler. In Caml the combination of inbuilt pointer equality and "mutable" made things sufficiently simple, and the ability to allocate at least some recursively linked objects without using "ref option" also helped. =20 ] ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr