Re: null values and sentinels

From: Anton Moscal (msk@post.tepkom.ru)
Date: Mon Jan 18 1999 - 11:05:42 MET


Date: Mon, 18 Jan 1999 13:05:42 +0300 (MSK)
From: Anton Moscal <msk@post.tepkom.ru>
To: Jerry Jackson <jrj@channelpoint.com>
Subject: Re: null values and sentinels
In-Reply-To: <8A24EC12044FD21195E200600895E0B34BFBC2@goat.channelpoint.com>

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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET