[C++-sig] Retiring "ref", etc.
David Abrahams
david.abrahams at rcn.com
Mon Jun 10 20:49:21 CEST 2002
From: "joel de guzman" <djowel at gmx.co.uk>
> > What I'm heading toward is a two-level interface: a smart pointer type
> > ("reference<>", or pick a better name) which can be null, for low-level
> > interfacing with Python, and a higher-level type, "object", which can
never
> > be null, and which provides a nice Python-objec-like interface.
>
> Hmmm, so it seems that we have two types which are strikingly
> similar to what we have in C++. 1) an object-reference that
> cannot be null and 2) an object-pointer that can be null. While
> object is indeed a nice name, the presence of another lower
> level class that can point to a null object seems to suggest
> (at least to me) the ref and ptr prefix. obj_ref and obj_ptr
> comes to mind. Or, if you want to keep the nice "object" as
> a name, just name the other "object_ptr". After all, this is a lower
> level class that the client should avoid using if possible, so the
> longer name is ok.
>
> object: cannot be null [high level interface]
> object_ptr: can be null [low level interface]
The problem is that object_ptr needs to be parametrized on the type it's
pointing at (e.g. PyObject, PyTypeObject...). object_ptr<PyObject> is
redundant and object_ptr<PyTypeObject> is sort-of inaccurate.
So my latest thought is that the smart pointer class is spelled "handle",
and the one currently spelled "ref" is spelt "handle<>". I could supply
typedef handle<> obj_ptr;
or
typedef handle<> hdl;
or
typedef handle<> objptr;
but I'm resisting: I hate unpronounceable names.
-Dave
More information about the Cplusplus-sig
mailing list