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 MAA18955 for caml-redistribution; Mon, 18 Jan 1999 12:10:26 +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 LAA31469 for ; Mon, 18 Jan 1999 11:05:52 +0100 (MET) Received: from post.tepkom.ru (relay.tepkom.ru [195.9.240.162]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA01488 for ; Mon, 18 Jan 1999 11:05:48 +0100 (MET) Received: from localhost (msk@localhost) by post.tepkom.ru (8.8.7/8.8.7) with ESMTP id NAA25552; Mon, 18 Jan 1999 13:05:42 +0300 Date: Mon, 18 Jan 1999 13:05:42 +0300 (MSK) From: Anton Moscal To: Jerry Jackson cc: "'caml-list@inria.fr'" Subject: Re: null values and sentinels In-Reply-To: <8A24EC12044FD21195E200600895E0B34BFBC2@goat.channelpoint.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis On Tue, 12 Jan 1999, Jerry Jackson wrote: > 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. The only known to me solution is the following: declare let rec foo_nil = {xxx=1; yyy = foo_nil}; and then use foo_nil as Nil constant. The main problem is the following: foo_nil can't be used in the matching. Anton E.Moscal