POV-Ray : Newsgroups : povray.off-topic : Programming language discussion : Re: Programming language discussion Server Time
3 Sep 2024 23:26:56 EDT (-0400)
  Re: Programming language discussion  
From: Warp
Date: 23 Oct 2010 02:21:28
Message: <4cc27ee7@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> "But null pointers can be useful!" I hear you cry. For this, Haskell has 
> the "Maybe" type. Basically, if you say "Foo", it will definitely, 
> always, be a Foo. But if you say "Maybe Foo", then it may or may not be 
> a Foo - and the type system *requires* you to explicitly check whether 
> it's "null" or not before you do stuff to it.

  It sounds a bit like references vs. pointers in C++: References in C++
cannot be null, they always have to point to an actual object. (Ok,
technically speaking you can force a reference to point to "null",
but that's undefined behavior, and checking if a reference is "null"
is more complicated than simply comparing it to 0 or NULL.)

  Of course the limitation with C++ references is that they are const:
You cannot modify a reference to point to another object. Once a reference
has been initialized, it cannot be modified anymore. It will point to the
one and same object until its scope ends. (I'm not exactly sure now why
this was deemed as necessary.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.