--- created_at: '2010-04-05T12:08:35.000Z' title: Objects are a poor man's closures (2003) url: http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html author: j_baker points: 132 story_text: '' comment_text: num_comments: 38 story_id: story_title: story_url: parent_id: created_at_i: 1270469315 _tags: - story - author_j_baker - story_1241717 objectID: '1241717' year: 2003 --- [Source](http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html "Permalink to RE: What's so cool about Scheme?") # RE: What's so cool about Scheme? * * * [[Date Prev][1]][[Date Next][2]][[Thread Prev][3]][[Thread Next][4]][[Date Index][5]][[Thread Index][6]] # RE: What's so cool about Scheme? * * * * _To_: "Guy Steele - Sun Microsystems Labs" <[address@hidden][7]>, <[address@hidden][8]> * _Subject_: RE: What's so cool about Scheme? * _From_: "Anton van Straaten" <[address@hidden][9]> * _Date_: Wed, 4 Jun 2003 13:13:21 -0400 * _Cc_: <[address@hidden][10]> * _Importance_: Normal * _In-reply-to_: <[200306041454.h54EsBh09407@sydney.East.Sun.COM][11]> * _Sender_: [address@hidden][12] * * * Guy Steele wrote: > Mike Newhall wrote: > At 08:23 PM 2003.06.03 -0400, Anton van Straaten wrote: > >I can sort of agree with that, but really, without closures, > >people will - and do - use all sorts of hacks anyway - > >objects, for example ;o) > > As an aside, although I don't remember the exact argument, Christian > Queinnec in LISP In Small Pieces made the case that, although > many people consider objects to be 'poor man's closures', closures > are in fact poor man's objects (in his opinion). > > A closure is an object that supports exactly one method: "apply". That's true from one perspective, and was what I was thinking of related to objects being used as hacks to work around lack of closures. A closure's simplicity can be an asset: classes and interfaces can get in the way of simple parameterization of behavior. Anyone who's tried functional programming in Java or C++ has encountered this - it can be done, but it's more tedious. If all you want to do is e.g. (map somefun mylist), being able to concisely define executable "objects" (closures), inline if necessary, is very useful. But from another perspective, the apply "method" of a closure can be used as a low-level method dispatch mechanism, so closures can be, and are, used to implement very effective objects with multiple methods. Oleg Kiselyov has a short article on the subject: Used in this way, closures can be said to be richer than objects because they can support many more capabilities than just a single language-provided method dispatch mechanism. With closures seen as a building block with which to implement objects, it's clear that objects are a poor man's closures. But a Smalltalker might say hold on, if you're going to all the trouble to implement these closure thingies in your language, since they're already a lot like objects, why not go all the way and make them "real" objects that can support an arbitrary number of methods, so that a closure is just one special-case kind of object? If your language only has these restricted closures, and you're forced to build an object system on top of them, it's clear that closures are a poor man's objects. Given this tension between opposites, I maintain that the question of closures vs. objects should really be a koan. I'll take some koanic license and combine Norman Adams (alleged source of "objects are a poor man's closures") and Christian Queinnec ("closures are a poor man's objects") into a single great Zen language master named Qc Na. I'll also take the un-humble step of inserting myself as student, since as I mentioned in the last paragraph of this message: ...I believe I did in fact gain some enlightenment from considering these two apparently opposing positions. Here goes: * * * 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. :) * * * * **References**: * [**RE: What's so cool about Scheme?][11]** * _From:_ Guy Steele - Sun Microsystems Labs * Prev by Date: [**RE: What's so cool about Scheme?][1]** * Next by Date: [**RE: What's so cool about Scheme?][2]** * Previous by thread: [**Re: What's so cool about Scheme?][3]** * Next by thread: [**RE: What's so cool about Scheme?][4]** * Index(es): * [**Date**][5] * [**Thread**][6] [1]: http://people.csail.mit.edu/msg03276.html [2]: http://people.csail.mit.edu/msg03278.html [3]: http://people.csail.mit.edu/msg03271.html [4]: http://people.csail.mit.edu/msg03273.html [5]: http://people.csail.mit.edu/maillist.html#03277 [6]: http://people.csail.mit.edu/threads.html#03277 [7]: mailto:Guy.Steele%40sun.com [8]: mailto:mike%40newhall.net [9]: mailto:anton%40appsolutions.com [10]: mailto:ll1-discuss%40ai.mit.edu [11]: http://people.csail.mit.edu/msg03269.html [12]: mailto:owner-ll1-discuss%40ai.mit.edu