object - 闭包和对象

标签 object functional-programming closures imperative

关闭。这个问题是opinion-based .它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题.

6年前关闭。



Improve this question




函数式编程 .. 就像经典 ( Mark Twain's type )。
在阅读有关 SICP 的另一篇文章时,人们正在谈论
关闭对那里产生的巨大影响,我想起了这一点,
我很久以前读过的

闭包是穷人的对象
对象是穷人的封闭

(不记得确切的来源,但它是程序员的罗塞塔石碑,或编程的禅宗,
或 tau 编程......谷歌变得如此拥挤以至于无法访问原始来源)

所以共同程序员......你有什么看法......
闭包是你一直缺少的东西……或者只是一些语法糖,
预处理器可以做什么!!

最佳答案

http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html

The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."

Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.

On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.

-- Anton van Straaten

关于object - 闭包和对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/501023/

相关文章:

javascript - 将具有相同属性的对象数组转换为具有数组值的一个对象

swift - 如何在 Swift 中编写通用函数来进行条件向下转型?

javascript - 什么时候 a => f(a) 不等同于 f?

scala - 函数式编程标量

swift - 我如何使用 navigationController?.popViewController(动画 : true) inside of a closure with no warnings and errors?

javascript - 你能说这是 Javascript Closure 的一个正确的例子吗?我们需要考虑避免闭包的地方在哪里?

java - 当传递的参数是不同对象的数组时,如何在方法中声明参数类型?

java - 从子类的arraylist到达父类方法

Swift 闭包通过引用捕获数组

javascript - 如何获取所有 LI UL 元素 ID 值并将它们放入 JavaScript 数组中?