not or null

Started by stellan, March 26, 2004, 10:11:27 AM

Previous topic - Next topic

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

Lutz

#1
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