乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: samifox

[编程交流] lambda , function , mapcar , a

[复制链接]

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 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.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 06:45:14 | 显示全部楼层
That does seem to be an inconsistency, especially since:
  1. (listp nil) ; Returns T
But 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
  1. (length nil) ;Returns 0(not nil) ;Returns T(atom nil) ;Returns T
So 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).
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 06:47:35 | 显示全部楼层
 
I agree.
 
For completeness, we also have:
  1. _$ (vl-consp nil)nil
 
As a test for a non-empty list.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 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?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 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.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 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.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 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:
  1. 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).
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 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.
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 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.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 18:56 , Processed in 0.976101 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表