[C++-sig] Retiring "ref", etc.

joel de guzman djowel at gmx.co.uk
Mon Jun 10 05:31:12 CEST 2002


----- Original Message ----- 
From: "David Abrahams" 

> you-eat-lots-of-bugs-if-you-ride-with-your-mouth-open-ly y'rs,
> dave

And yes, this is why I'm still lurking in the background and
keeping my mouth shut ;-) I was afraid (and shy) that I might
embarass myself publicly with potentially dumb remarks.
Duh ;-) So pardon me if I am not yet quite familiar with the
Python/BPL culture. I've been really rather itching to join in.

> there's a small fly in that ointment: while it might make some sense to
> allow a null reference, it makes no sense at all to think of a null object.
> I'm not talking about None, here: I mean a null PyObject*. 

object, as a name, seems to be perfect and sensible. I am not
quite sure about the implications but isn't it possible to make
the semantics of a null PyObject* be like a None object? 

> Unfortunately, it's sometimes important to be able to manage a 
> possibly-null PyObject*, 

I've written run-time libraries for dynamically typed interpreters before.
The core data type I always use is a C++ reference counted object
called 'value' [ object is a better name ]. In my implementation, there
is no null (in the C/C++ sense)-object. There's always an object being 
pointed to. There is however a nil object, akin to python-None. To
keep the implementation from having to construct/allocate destruct/
deallocate nil-objects, I keep only one that goes into scope at the
very beginning and out of scope at the very end. All nil objects share
this singleton.

> so it appears that reference<> must stay alive in some form or other.

IMHO, I don't see how a null reference makes more sense than 
having a null object. If you ask me, I'm more concerned about
having both a null-reference and a reference to None with different 
behavior.

//////////////////////////////////////////////
So, there's my 2c worth. Right now, I am still gaining confidence
with BPL and Python so I'm rather quite, ummmm, shy in the
presence of Python/BPL gurus as most of you are ;-)

Cheers,
--Joel











More information about the Cplusplus-sig mailing list