From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA16199 for caml-redistribution; Mon, 18 Oct 1999 16:10:13 +0200 (MET DST) 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 LAA15591 for ; Sun, 17 Oct 1999 11:25:00 +0200 (MET DST) Received: from ruby (pm1-0.triode.net.au [203.63.235.16]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA10466 for ; Sun, 17 Oct 1999 11:24:55 +0200 (MET DST) Received: from maxtal.com.au (IDENT:root@localhost [127.0.0.1]) by ruby (8.9.3/8.9.3) with ESMTP id TAA18936; Sun, 17 Oct 1999 19:18:56 +1000 Sender: weis Message-ID: <3809947E.A3540F11@maxtal.com.au> Date: Sun, 17 Oct 1999 19:18:54 +1000 From: skaller Organization: Maxtal X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en MIME-Version: 1.0 To: Manuel Fahndrich CC: caml-list@inria.fr Subject: Re: Proposal for study: Add a categorical Initial type to ocaml References: <783D93998201D311B0CF00805FEAA07B7E8F6C@RED-MSG-42> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Manuel Fahndrich wrote: > > I did not word what I meant correctly. i thought you did OK .. >In the case of initial values, errors > can occur anywhere in the code, namely, whenever I access an uninitialized > value. Since these values can live in records, and the records can be passed > around, the error can occur anywhere. > > Now, with a well-defined and encapsulated use of Obj.magic, such errors can > be avoided. E.g. in the extensible array case, I can write the module in > such a way that no matter what code I write outside of that module (not > using Obj.magic), it cannot result in an error. I'm sorry. I do do not follow. You argument is comparative, and appears unsound because it fails to make a distinction. The magical encapsulation of Obj.magic within a module or class, can be applied to initials just the same: maintaining the invariant 'uninitialised values are initialised before use' is the same in both cases, only the value representing it differs. Where 'initial' might be used, obj.magic could be used too. References to both may be propagated without error (and indeed that is the whole point): the only difference is that using an initial value is guarranteed to cause an exception to be raised, whereas using a magical value offers no guarrantees, and could core dump. The initial value is therefore easier to debug. The other difference seems to be that it is polymorphic whereas obj.magic needs explicit casting. -- John Skaller, mailto:skaller@maxtal.com.au 1/10 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller downloads: http://www.triode.net.au/~skaller