[C++-sig] Re: Retiring "ref", etc.
daveh at cadlink.com
Mon Jun 10 19:58:21 CEST 2002
"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:007901c21080$b932aec0$6601a8c0 at boostconsulting.com...
> Python is written in 'C'. What roles can a null PyObject* have?
> Default-constructed smart pointers need to have a value.
> Python tuples start out initially empty (not full of None) when you
> construct them.
> ...and so forth.
Another awkward twist is that some of the python API functions accept a NULL
PyObject* as a valid parameter. Which implies a 'NULL' reference should be
allowed which is not symantically an error condition. However I don't think
there any functions that can return a valid NULL apart from some of the
MACRO versions with no error checking.
I don't think it is unreasonable to construct a new smart pointer that holds
a NULL pointer as it currently does.
However for return values may be we should have a different smart pointer
called something like result_reference. We can then allow conversions
between the two that would check if result_reference was valid, before
converting to a regular reference.
More information about the Cplusplus-sig