Page 1 of 1

not or null

Posted: Fri Mar 26, 2004 6:11 pm
by stellan
just a minor point. I think that (null something) feels more intuitive than (not something) if you are testing for nil or the empty list. Of course I can define a function null myself but still...

stellan

Posted: Fri Mar 26, 2004 8:07 pm
by Lutz
this would define a global null which would works just like not and perform as efficiently:

(constant (global 'null) not)

you also could do one after the other:

(constant 'null not)
(global null)

But the first way is more elegant, now you can do:

(null '()) => true

(null nil) => true

Using 'constant' instead of 'set' will protect it against inadvertant change and the 'global' function makes 'null' available in any context/namespace, like the original 'not'.

Calling it 'null' makes it more like a predicate 'null?' while 'not' emphasizes its character as a logical negation operator.

Lutz