On Fri, 18 Nov 2016, Riccardo (Jack) Lucchetti wrote:
On Fri, 18 Nov 2016, Allin Cottrell wrote:
> Anyway... we could regularize this by dropping the current practice of
> manufacturing an empty list corresponding to no-argument, although this
> would mean that "null" has a somewhat different meaning on the right-hand
> side of an assignment (empty object) and as the default for a function
> argument (non-existent). Urgh. It's hard to see a way out of this that's
> not rather nastily backward-incompatible.
I must have used the idiom "list X = null" several hundreds of times in my
scripts. There's no way one could make this illegal without wreaking havoc.
Totally agreed, we can't do that. But less obviously havoc-wreaking
would be to change the behavior of list function-parameters with a
"null" default so that the callee gets no list rather than an empty
list when no argument is supplied. Not that I'm actually recommending
that. It might well break a bunch of scripts too.
OTOH, "nelem(X) == 0" is a very nice and compact logical
condition that inbe
could use in place of isnull() or similar functions.
Sure, it works fine, for lists. But Sven's point is that you have to
use a different argument-checking construction for lists than you use
for function-arguments of other types that support a "null" default
value.
The easiest (though not the tidiest) thing to do here is just be clear
in the doc that lists are special in this respect.
Allin