On Mon, 26 Oct 2015, Sven Schreiber wrote:
Am 26.10.2015 um 19:38 schrieb Allin Cottrell:
> On Mon, 26 Oct 2015, Sven Schreiber wrote:
>> <hansl>
>> open denmark # dummy dataset
>>
>> list lh = null
>>
>> if isnull(lh)
>> print "yep" # doesn't get printed
>> endif
>> </hansl>
>>
>> I actually can understand conceptually that the list 'lh' is
"empty"
>> rather than non-existing, but then I think either there should be this
>> (new) keyword 'empty' for lists, or isnull(lh) should return True/1 in
>> this case.
>
> The above looks funny, I agree. However, it clearly corresponds to the
> documentation of isnull():
>
> "Returns 0 if name is the identifier for a currently defined object, be
> it a scalar, a series, a matrix, list, string or bundle; otherwise
> returns 1."
>
> Is your suggestion that one should be able to say
>
> list lh = empty # instead of "= null"
>
> ?
Perhaps this might be a solution, yes; see also below.
At this point I'm inclined to think that (besides any other issues),
offering "null" as an initializer for lists and bundles was not a
great idea.
It was tempting for C coders, since NULL is a standard initializer
for pointer-y objects in C. But the analogy is not very good: unlike
a hansl object set to "null", a C null-pointer is not an "empty
object" (e.g. a list or string in good standing but of length zero),
it's a pointer to nowhere, and with a few exceptions it's not a
valid function argument (many C library functions will crash if you
pass a NULL pointer as an argument). So "empty" might have been a
better word to choose for the hansl initializer.
Whether it would be a good idea to make a change now is another
question.
Allin