class(java)和closure(javascript)之间的区别? [英] Difference between class(java) and closure(javascript)?

查看:211
本文介绍了class(java)和closure(javascript)之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白闭包比类更强大。看起来像我可以实现相同的行为闭包使用类。

I don't understand how closure is more powerful than class. It looks like I can achieve the same behavior of closure using class. Any help would be appreciated

推荐答案

关闭是穷人的对象/对象是穷人的关闭

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

对于懒惰:


尊敬的主人Qc Na是
和他的学生Anton一起走。
安东说:主人,我有
听说对象是一个非常好的
的东西 - 这是真的吗? Qc Na看起来很漂亮,他的学生回答说,
愚蠢的学生 - 对象只是一个
的穷人的关闭。

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:The
Ultimate ...系列文章和其
表兄弟,并实现了一个小的
Scheme解释器与
闭包的对象系统。他
学到了很多,并期待
通知他的主人他的进步。

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回答说,用他的棍子击中
Anton,说当
将你学习?闭合是一个穷人
人的对象。

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

这篇关于class(java)和closure(javascript)之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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