jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy T. Fielding" <field...@gbiv.com>
Subject Re: 3.1.3.1 Removing Items
Date Sat, 21 Jul 2007 01:28:21 GMT
On Jul 20, 2007, at 8:31 AM, IvanLatysh wrote:

> Julian Reschke wrote:
>
>> Well, in the JCR property model "null" and non-existance are the  
>> same. As far as I can tell, the same applies to WebDAV properties,  
>> RDF and the XPath data model.
> I can't say for WebDAV, but I can say that for FS file with length  
> 0 and no file are different things.
> And you are wrong about XPath, Here is an example:
>
> <data>
>   <distance case="1" unit="km">120</distance>
>   <distance case="2" unit="">130</distance>
>   <distance case="3">140</distance>
> </data>
>
> exists(/data/distance[@case='1']/@unit) = true
> exists(/data/distance[@case='2']/@unit) = true
> exists(/data/distance[@case='3']/@unit) = false
>
> The null is a value, even it has a special meaning, but it is a  
> value and have the same weight as for instance 10 or 100 or 0 or  
> Integer.MAX_VALUE.

I am sorry, but that is factually incorrect.  Please look it up in any
book on programming languages.  Null (or its synonyms, like undef in  
perl)
is a language feature for indicating that a name (pointer, object,
reference, etc.) does not exist.  It is never a data value in itself,
though it is sometimes called a "special value" or "distinguished value"
because if its capability for assignment.  Null is never an integer,
even though C will convert null to 0 within an int context (by design).

NUL (ASCII 0) is a data value.  Likewise, the parent's property
structure is a data value. The absence of a property for a given
parent is the value you are looking for, and its interpretation is
dependent on the defaults set for that data structure.  Most XML has
default attribute values that must be assumed by the reading
application if no attribute is present.

In perl, setting a name to undef (null) deletes it.  In C, setting
a pointer to null makes it undereferenceable.  Within reference
counting systems, setting the last reference to null enables deletion.
In Java, setting an object reference to null is the same as deleting
that object if no other references exist.

Within a data model, there are no language references.  There is no
value of null within hierarchical data structures like JCR.  There is
merely the presence or absence of names.  That is why setting a
property value to null causes the property to be deleted, just like
it does in perl.  The only equivalent to null within JCR would be
a reference property with an empty string value, which is generally
considered to be an error.

All of the examples you have given are just unwise design.  Null is
not an integer.  Null is not a string value.  When you read XML that
contains default attribute values, the reader of the XML is responsible
for filling in the default for its data model when an attribute is
absent.  If you are using null to indicate data values then your
system is going to encounter a great deal of errors due to language
side-effects regarding the special meaning of null.  Null is special
specifically so that it won't be mistaken for any normal data value,
thereby allowing the language to indicate NPE instead of accidentally
dereferencing some arbitrary memory location.

Cheers,

Roy T. Fielding                            <http://roy.gbiv.com/>
Chief Scientist, Day Software              <http://www.day.com/>


Mime
View raw message