惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - NeilChen

恢复 Windows 7 的“回到父目录”按钮 FireFox 脑残的安全设定 SQL Server 事务自动回滚 下载 infoq 网站视频 也做了一下腾讯前端面试题 Select prototyping tools Lisp in Small Parts TechTalk by Peter Seibel on Common Lisp 时隔3年,再做双倍超立方数的题目,这次用Lisp Racket, SICP stream learning Operation is not valid due to the current state of the object Common Lisp 在 Windows 上的开发环境比较 翻译英文技术文章是一件很可耻的事情吗? 写了个博客备份的 ruby 程序 体验 Clozure CL 试用 Portable Allegro Serve Windows XP, Emacs, CLisp, SLIME 关于 Business Rule Engine Irony - 一个 .NET 语言实现工具包
lisp 笔记 - 闭包
NeilChen · 2012-03-21 · via 博客园 - NeilChen

一般语言由 primitives 组成, lisp 由 meta-primitives 组成。lisp 不定义 primitives. “Any time there is a primitive, there is a barrier, a non-orthogonality, in the design of the system.”

let 用来创建 lexical scope.

lexical scope 的好处是这些绑定在编译后不需要为其实际分配任何内存 slot, 甚至一些显而易见的逻辑会被直接编译优化成简单的常量。

lisp 中 dynamic scope 通过 defvar 创建,类似于全局变量。dynamic scope 的变量必须在 environment 中开辟实际内存区域(runtime). 因此性能可能稍微不如 lexical scope. dynamic scope 的变量在遇到同名的 lexical scope 变量时可能被 shadow. shadow 的过程实际是在进入 lexical scope 时在 dynamic scope 的那个 environment 中先备份原来的值,然后改写该值,在退出 scope 前再次从备份中恢复原来的值。

let over lambda 是用来创建闭包的惯用法;

闭包本质是 state + 1个 function.

object 是 state + multiple functions.

在 let over lambda 结构中用 values 返回多个引用了相同 bindings 的 lambdas,可以实现 class 和 object.

let over lambda over let over lambda 可以实现 class variable (static variable).

let + lambda 的各种组合用法可以实现大多数语言中的 OO 系统特性。该组合甚至可以实现更独特的一些应用场景。抛开继承,在大多数情况下一个 OO 系统是不必要的。OO 系统是基于 let 和 lambda 的一种特定实现。