闭包和对象 [英] closures and objects

查看:29
本文介绍了闭包和对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Functional programming .. is like classic ( Mark Twain's type). While reading another articles about SICP, where people are talking about the great impact closures had on there thinking, i got reminded of this, which i read ages ago

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

Closures are poor man's objects Objects are poor man's closure

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

( Can't recall exact source but it was programmers rosetta stone, or zen of programming, or tau of programming ... google has become so crowded that can't go to original source )

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

So co-programmers ... What is your take ... are closure something that you were always missing .. or just some syntactic sugar, which a preprocessor can do !!

推荐答案

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

可敬的大师 Qc Na 和他的学生 Anton 一起散步.希望提示师父讨论,安东说:师父,我听说了物件是很好的东西——这是真的吗?"Qc娜可怜兮兮的看着他的学生回答说:愚蠢的学生 - 对象只是一个穷人的关闭."

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."

受到惩罚,安东离开了他的主人,回到了自己的牢房,打算研究闭包.他仔细阅读了整个Lambda: TheUltimate..."系列论文及其表亲,并实现了一个小具有基于闭包的对象系统的方案解释器.他学到了很多,而且期待将他的进展告知他的主人.

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.

在与 Qc Na 的下一次散步中,Anton 试图通过以下方式给他的主人留下深刻印象说:师父,这件事我仔细研究过,现在明白了那个对象真的是一个穷人的闭包." Qc Na 通过击打回应安东用他的手杖说:你什么时候学会?关闭是一个穷人的对象."那一刻,安东开悟了.

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

这篇关于闭包和对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆