neophoible 发表于 2022-7-6 06:43:54

Does the argument also include a reference to getting input? In AutoLISP, nil is treated as an empty list, though its type is not LIST (inconsistency detected?). Indication of the default selection is returned as nil for everything except getstring. I would consider that a pretty simple approach, making for easy handling.Explicit input, on the other hand would most often (but not always) be of a different type than LIST, that is, user input is often of variable type for the same query, and it can even include keyword responses, all easily handled in AutoLISP.

irneb 发表于 2022-7-6 06:45:14

That does seem to be an inconsistency, especially since:(listp nil) ; Returns TBut note, nil is a special case. In Lisp it's considered the same as false, an empty list and a "nothing" item. So you get
(length nil) ;Returns 0(not nil) ;Returns T(atom nil) ;Returns TSo IMO type is doing it correctly. Nil can be any of the types, so rather than indicate yet another type which means all it simply returns nil (as in not any type).

Lee Mac 发表于 2022-7-6 06:47:35

 
I agree.
 
For completeness, we also have:

_$ (vl-consp nil)nil
 
As a test for a non-empty list.

neophoible 发表于 2022-7-6 06:53:29

Very interesting--I mean saying that nil can be any of the types. I'm not sure what that's supposed to mean, but if left at that, it sounds very misleading. I think the reason is obvious, as you cannot treat it as just any of the types.If you do, you will soon find out that it is not an Integer, nor a Real.Thus, numberp also does it right. And if you use nil as an argument just whenever, you will certainly generate errors. What say ye?

Lee Mac 发表于 2022-7-6 06:54:50

 
By 'any of the types' I think Irné meant that nil can be viewed either as an atom (as in a boolean false value), or as an empty list - i.e. any of these two types. The fact that an empty list is equivalent to a boolean false value is incredibly useful in conditional statements testing whether a list has been processed, e.g. when recursively processing a list.

neophoible 发表于 2022-7-6 06:58:54

Yes, comparatively speaking, it's a handy little guy.
 
BTW, I heard Chuck Norris once counted down to nil...twice.

irneb 发表于 2022-7-6 07:02:29

Yep, as used it's both an atom and a list. 
I've been working at extending AutoLisp for some time now. Mostly in the research phase, but I've been investigating redoing the entire engine. And what most Lisp implementations seem to have in common is that nil is the base class type, while atom and list are derived from that. Then the other types are derivatives of those. So it actually does seem that nil is the "daddy" of all other types.
 
If you look at it from an object oriented perspective:
NIL - Atom   - Number   - Integer   - Real   - EName   - etc. - Sequence   - Cons   - String   - etc.So while everything is a nil (like in both cars and buses are vehicles), nil is not everything (like in a vehicle is not necessarily a bus).

neophoible 发表于 2022-7-6 07:03:06

Lee Mac & irneb, thanks for the explanations.Interesting how such a seemingly negative little guy could be the basis for the entire DNA of the LISP universe I've been enjoying so much all these years.Perhaps not too surprising, though.

irneb 发表于 2022-7-6 07:06:47

I see nil in a similar light as zero, it makes the programming a lot simpler - in the same way as 0 did for maths after the Greek & Roman number systems were superseded by the Arabic numbers we use these days. 
Nil is not exclusive to Lisp, though Lisp uses it much more prevalently. You do get Null in other languages like C/C++/C#/VB/Pascal, but more often than not it's only used to distinguish uninitialized variables / pointers to objects. Very seldom is it equivalent to a false, an empty collection as well as a blank value, like it is in Lisp.

neophoible 发表于 2022-7-6 07:10:55

Or maybe more like the Origin of origins of coordinate systems--what everything else must be referenced to. 
Yeah, that. In our LISP it looks more like the beginning on which to build--the primordial (of) list.
页: 1 [2]
查看完整版本: lambda , function , mapcar , a