Proposing a convention for null ObjectPaths

Alp Toker alp.toker at collabora.co.uk
Mon Aug 6 08:43:22 PDT 2007


Recently there has been some demand for nullability, particularly in
variants. This was one of the issues discussed at GUADEC
(http://lists.freedesktop.org/archives/dbus/2007-July/008154.html) and
seems to come up quite often on the list.

The concept of nullability is expressed in two ways in the platform I'm
working with (the CLR):

  * The first and most common case corresponds directly to null
pointers. In this case, a null will be stored in memory instead of a
valid object reference. Primitive types cannot be marked null in this
scheme.

  * Nullable types: With C# 2.0 nullable types, it's possible for any
value type, including structures, to be nulled.

I believe that the second case may be over-kill for the D-Bus wire
protocol, while a convention for specifying the first case could help to
solve real issues that developers are facing with D-Bus.

(I gather there is still some demand for a complete overhaul of the type
system to support real nullable primitive types, but my concerns here
would be that this is a significant new feature and will change the way
things work all the way from the marshaling code in every implementation
up to each of the bindings, particularly considering that there is no
clear mapping of empty primitive values to the type systems of many
languages.)

So, if we take a look at setting a convention for an ObjectPath
representing null, it's apparent that this provides a fairly elegant
extension to the protocol, requiring only minimal modification to
ObjectPath validation code and little or no change to any core
marshaling code: my proposal for a null ObjectPath would be for the
string representation of the path to have a length of 0. This fits well
with the conceptual model where ObjectPaths are mapped to pointers.

This convention can then be used to express a null variant as a variant
containing an ObjectPath of length 0.

I'd like to kick off some discussion of how this can be implemented at
the protocol level, as well as how it fits into the conceptual models in
various bindings and implementations. Does this proposed convention work
for you?




More information about the dbus mailing list