From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: not null
Date: Thu, 5 Mar 2009 09:42:46 +0100
Date: 2009-03-05T09:42:37+01:00 [thread overview]
Message-ID: <1pji2yyih0ot4$.1kjzwo0k6285p$.dlg@40tude.net> (raw)
In-Reply-To: a9bbaecc-7bcf-4f98-bb58-7ec02827adb3@o2g2000prl.googlegroups.com
On Wed, 4 Mar 2009 17:54:16 -0800 (PST), Adam Beneschan wrote:
> On Mar 4, 12:38 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>
>> Recursive types is not the single case where references are used. For smart
>> pointers not null constraint is very useful.
>
> Right, I didn't say a "not null" constraint isn't useful; I'm just
> saying that it's also useful to have access objects that *can* be
> null, if needed. Actually, I'm not clear on whether anyone disagrees
> with that. This points to a curiosity in Hoare's abstract: first he
> implies that inventing "null references" was a big mistake, and then
> he says "declarations for non-null references" is the solution. If
> allowing null references is a mistake, then the solution is to
> disallow them---not to allow the programmer to declare a reference
> that may not be null, right?
Right, this is what smart pointers use, not a constraint in the sense of an
Ada subtype, but a type that does not have null as a value. A smart pointer
is always valid.
> I think maybe Hoare misstated the
> problem. The mistake wasn't inventing null references; the mistake
> was not providing a way for the programmer to disallow selected
> reference types or variables (objects) from being null. This
> misstatement may have led to some confusion on this thread.
Yes, there are two cases: dynamically constrained references and statically
constrained ones. Both have their uses.
Concerning the invention of null, I can understand Hoare's point. There is
a comparable case with IEEE 754, where ideal values like NaN were invented.
Sometimes this adds a lot of pain, which could be spared. Sometimes it does
not.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2009-03-05 8:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-04 14:44 not null Georg Bauhaus
2009-03-04 14:56 ` Hyman Rosen
2009-03-04 15:22 ` Georg Bauhaus
2009-03-04 16:16 ` Adam Beneschan
2009-03-05 14:24 ` Georg Bauhaus
2009-03-05 16:07 ` Adam Beneschan
2009-03-06 1:07 ` Hibou57 (Yannick Duchêne)
2009-03-04 16:09 ` Adam Beneschan
2009-03-04 20:38 ` Dmitry A. Kazakov
2009-03-05 1:54 ` Adam Beneschan
2009-03-05 8:42 ` Dmitry A. Kazakov [this message]
2009-03-05 1:32 ` Brian Drummond
2009-03-05 1:47 ` Adam Beneschan
2009-03-05 11:32 ` Brian Drummond
2009-03-05 15:06 ` Dmitry A. Kazakov
2009-03-05 13:57 ` Georg Bauhaus
2009-03-05 19:53 ` Jack Mitchell
2009-03-05 8:49 ` Jacob Sparre Andersen
2009-03-05 16:10 ` Adam Beneschan
2009-03-05 17:20 ` Jacob Sparre Andersen
2009-03-06 1:04 ` Hibou57 (Yannick Duchêne)
2009-03-06 12:01 ` Harald Korneliussen
2009-03-06 12:43 ` Jacob Sparre Andersen
2009-03-06 13:05 ` Harald Korneliussen
2009-03-06 15:21 ` Dmitry A. Kazakov
2009-03-06 16:59 ` Harald Korneliussen
2009-03-06 17:48 ` Dmitry A. Kazakov
2009-03-06 20:05 ` Georg Bauhaus
2009-03-06 21:31 ` Dmitry A. Kazakov
2009-03-04 16:19 ` Robert A Duff
2009-03-04 20:39 ` Colin Paul Gloster
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox