nil and 'nil
Posted: Wed Mar 19, 2008 10:12 pm
Everyone knows that in newlisp, unlike other lisps, nil is not the same as empty list, although both are considered false in boolean contexts. Let me remember:
But not everyone probably know that in newlisp there are not two, but three false values, two of them are equal to each other!
What the bogus? Let us see:
So far so good. Where the problem is?
'nil is symbol, while nil is not. More then:
A flag argument may be nil only, not 'nil.
Some low-level investigation:
So, the conclusion: nil and 'nil are different values, although they are both boolean false and are equal by standard equality test.
Now let me imagine myself being a celebrity and giving an interview:
Q: Do you think this is an error? Should it be fixed?
A: Definitely no. This is a useful compromise, which allows a lot of code to be written in a natural way. I prefer to keep it this way.
Q: Do you think this should be documented?
A: Definitely YES!
;-)
Code: Select all
> (if nil 'yes 'no)
no
> (if '() 'yes 'no)
no
> (= nil '())
nil
What the bogus? Let us see:
Code: Select all
> (if nil 'yes 'no)
no
> (if 'nil 'yes 'no)
no
> (= nil 'nil)
true
Code: Select all
> (symbol? 'nil)
true
> (symbol? nil)
nil
Code: Select all
> (ends-with "abc" "[a-z]" nil)
true
> (ends-with "abc" "[a-z]" 'nil)
value expected in function ends-with : 'nil
Some low-level investigation:
Code: Select all
> (& 0xf ((dump nil) 1))
0
> (& 0xf ((dump 'nil) 1))
5
Now let me imagine myself being a celebrity and giving an interview:
Q: Do you think this is an error? Should it be fixed?
A: Definitely no. This is a useful compromise, which allows a lot of code to be written in a natural way. I prefer to keep it this way.
Q: Do you think this should be documented?
A: Definitely YES!
;-)