TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: highflyingbird on June 20, 2012, 01:37:52 PM
-
look at this:
_$ (> nil 0)
nil
_$ (< nil 0)
T
_$ (< nil -2147483647)
T
_$ (* -1e200 1e200)
-1.#INF
_$ (< nil -1.#inf)
nil
So,what number is for nil?
maybe it's a stupid question.just a little curious.
-
nil is not a number, but rather a null value, and hence '<' and '>' will rank a symbol with value over one without.
Consider also:
-
** Lee posted before I could. LoL
Nil does not have a constant numerical value, as for example, Pi.
A simple, perhaps incomplete, way of looking at this is that Nil = Nothing (VB), or Null (C#), where zero ( 0 ) is in fact greater than nothing, to use your example.
... Make sense?
-
A simple, perhaps incomplete, way of looking at this is that Nil = Nothing
I am Nil :cry:
-
A simple, perhaps incomplete, way of looking at this is that Nil = Nothing
I am Nil :cry:
You're a member of TheSwamp, aren't you? :-)
-
We, are The Knights Who Say Nil. In return for our assistance we demand you bring us... A SHRUBBERY! :lmao:
-
what number is for nil?
number != 42;
-
A simple, perhaps incomplete, way of looking at this is that Nil = Nothing (VB), or Null (C#), where zero ( 0 ) is in fact greater than nothing, to use your example.
A "less simple" ;) "more complete way" :lmao:
http://en.wikipedia.org/wiki/Null_pointer#Null_pointer (http://en.wikipedia.org/wiki/Null_pointer#Null_pointer)
So in C/C++ a NULL is some constant integer value which is defined as a memory address which is impossible to be used. At least in most implementations of C/C++. This is probably why non-lispers think of nil as having some sort of value constant.
In Lisp, nil is the "base" symbol ... it's equivalent to an empty list. In AutoLisp it IS actually an empty list:(= nil '()) ;returns T
And True/False is also implemented differently in other languages. E.g. in VB False = 0, and True = -1 ... that's because of the way computers store signed integers (at least in the case of VB's computers that is). E.g. a 8-bit 0 is stored as a bit-array of 00000000, while the usual method of denoting a negative uses 2's compliment (http://en.wikipedia.org/wiki/Two%27s_complement), which means -1 is stored as 11111111 ... see why these 2 values were chosen as False and True respectively?
@HyflyingBird: Consider this, (+/-)1.#inf is actually undefined and simply used as an indication that the double float has reached one of its limits. It has no value of it's own - thus it evaluates to nil when used (as lisp interprets -1.#inf as a symbol name, which doesn't contain a value, and thus it's value IS nil):(+ -1.#inf)
; error: bad argument type: numberp: nil
(= nil -1.#inf)
T
(< nil (* -1e200 1e200))
T
I.e. nil is considered "smaller than anything else" in Lisp ... but it's not necessarily designed that way, it's more likely just a function of the implementation of the lisp interpreter/compiler.
-
@HyflyingBird: Consider this, (+/-)1.#inf is actually undefined and simply used as an indication that the double float has reached one of its limits. It has no value of it's own - thus it evaluates to nil when used (as lisp interprets -1.#inf as a symbol name, which doesn't contain a value, and thus it's value IS nil):(+ -1.#inf)
; error: bad argument type: numberp: nil
(= nil -1.#inf)
T
(< nil (* -1e200 1e200))
T
I.e. nil is considered "smaller than anything else" in Lisp ... but it's not necessarily designed that way, it's more likely just a function of the implementation of the lisp interpreter/compiler.
irneb,Thank you very much.
I asked this question, just wanted to mention a thing: NIL is comparable.so don't fall into this trap.
I learned a lot,thank everyone again.
-
just wanted to mention a thing: NIL is comparable.so don't fall into this trap.
This can be useful in some situations, for example, the test:
Can be reduced to:
I actually use this logic when unloading dialog handles. :-)
-
And True/False is also implemented differently in other languages. E.g. in VB False = 0, and True = -1 ...
May be this is is true with VB6 or VBA, but VB.net is quite confusing:
CInt(True) returns -1 like in older VB versions.
Convert.ToInt32(True) returns 1 like in other dotNET languages (see here (http://www.theswamp.org/index.php?topic=41187.msg463463#msg463463)).
About nil, there was this thread (http://www.theswamp.org/index.php?topic=39888.msg451877#msg451877).
-
Italy:1 England: nil
-
Italy:1 England: nil
:-(
-
Hello,
So,what number is for nil?
LISP is weakly typed, it is not a matter of numbers
Not knowing how to speak English correctly, here's an example that I hope sufficiently explicit…
_$ (< nil T)
T
_$ (> nil T)
Nil
A+
-
Italy:1 England: nil
:-(
my apologies :cry:
-
Italy:1 England: nil
:-(
my apologies :cry:
Thanks, though, we didn't really put on much of a performance - I think we were just holding out til penalties, then hoping for some luck :wink:
-
What a pity!