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 SAA14318 for caml-redistribution; Tue, 12 Jan 1999 18:45:51 +0100 (MET) 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 QAA22644 for ; Tue, 12 Jan 1999 16:50:33 +0100 (MET) Received: from talisker.channelpoint.com (talisker.channelpoint.com [208.226.244.33]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id QAA23327 for ; Tue, 12 Jan 1999 16:50:31 +0100 (MET) Received: from goat.channelpoint.com (goat.channelpoint.com [10.96.2.2]) by talisker.channelpoint.com (8.9.1/8.9.1) with ESMTP id IAA25651 for ; Tue, 12 Jan 1999 08:50:20 -0700 (MST) Received: by goat.channelpoint.com with Internet Mail Service (5.0.1457.3) id ; Tue, 12 Jan 1999 08:50:20 -0700 Message-ID: <8A24EC12044FD21195E200600895E0B34BFBC2@goat.channelpoint.com> From: Jerry Jackson To: "'caml-list@inria.fr'" Subject: null values and sentinels Date: Tue, 12 Jan 1999 08:50:19 -0700 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1457.3) Content-Type: text/plain Sender: weis Hello, I'd like to know what the recommended solution to the following situation is... I'd like to create a type like: # type foo = {xxx: int; mutable yyy: foo};; so that I can add nodes by mutating the "yyy" slots. Unfortunately, it seems that I must create a sentinel value of type "foo" to stand for a null pointer. This works but I'd like to be able to use pattern matching on the value of yyy so as to get compile-time warnings if I forget to check for null. So, I tried this: # type foo2 = {xxx: int; mutable yyy: bar} and bar = Empty | Pointer of foo2;; This works (i.e. I can match on yyy in the way that I want), but it _seems_ like this will create an extra indirection object in the yyy slot. Whether it does or not seems to be a compiler question to me... "Pointer of foo2" could be collapsed into foo2 by the compiler. Is it? How should I approach this situation? Thanks for any help, Jerry Jackson