|
Prev: You want abbreviations? You can't handle abbreviations!
Next: Hot Shop Audemars Piguet Royal Oak Watches - Audemars Piguet Minimum Price
From: Stefan Nobis on 5 May 2008 11:01 "xahlee(a)gmail.com" <xahlee(a)gmail.com> writes: > People, closures is effectively just function using global vars, > alright? No, you just can't emulate closures completley by using global vars, because your global vars have to be defined at compile time but new closures may be generated at run time. The only way to make your statement true, is to rub out all common meaning of global vars and substitute it's meaning with something like 'my global var is a complex machinery, that may store dynamically an unbound number of data'. A closure is, to try a more formal, mathematical definition, an object consisting of two components: a function body (the code) and an accompanying environment (just a bunch of data). The important issue here is that a single function body (= piece of code found in the sources) may be used to create (unbound) many *different* closures (each with quite different data), all existing at the same time in parallel (so just resetting global state before each function call based on a bound, static number of global variables, is not enough to simulate this -- you need at least something like a (global) dictionary and quite some bookkeeping code). No Common Lisp, even no source code. I hope, now you are satisfied and you see, you misunderstood the concept. BTW: I find it really exceptional to reason about programming concepts and at the same time to declare concrete examples with source code to be a hindrance in understanding -- every other people I know of see this quite the other way round: Concrete examples are helpful to better understand programming concepts. (And in a group like comp.lang.lisp examples in Lisp came quite naturally, don't you think so?) -- Stefan.
From: viper-2 on 6 May 2008 15:45 On May 6, 3:00 pm, Rainer Joswig <jos...(a)lisp.de> wrote: > In article > <7a360a2d-c283-41d4-a4f5-40c176fb4...(a)a70g2000hsh.googlegroups.com>, > Well, RMS worked on the Lisp Machine. He even wrote manuals for it. > He wrote for example the Zmail manual > and co-wrote the Window System Manual. He knew the system very well. > Including Flavors, the object system. He himself wrote an > object-system before there was Flavors. Lisp Machine Lisp was > dynamically scoped with some support for closures. > There was more experience with dynamically scoped Lisps at that time. > Hmmm, thank you Rainer; that was informative. I didn't realize that RMS had written an object system. I must remember to refer to you when I'm looking for historical tidbits. agt
From: Rainer Joswig on 6 May 2008 16:00 In article <2f9bb421-187a-4820-a515-03fc41d141b6(a)m45g2000hsb.googlegroups.com>, viper-2 <visionat(a)mail.infochan.com> wrote: > On May 6, 3:00 pm, Rainer Joswig <jos...(a)lisp.de> wrote: > > In article > > <7a360a2d-c283-41d4-a4f5-40c176fb4...(a)a70g2000hsh.googlegroups.com>, > > > Well, RMS worked on the Lisp Machine. He even wrote manuals for it. > > He wrote for example the Zmail manual > > and co-wrote the Window System Manual. He knew the system very well. > > Including Flavors, the object system. He himself wrote an > > object-system before there was Flavors. Lisp Machine Lisp was > > dynamically scoped with some support for closures. > > There was more experience with dynamically scoped Lisps at that time. > > > > Hmmm, thank you Rainer; that was informative. I didn't realize that > RMS had written an object system. I must remember to refer to you when > I'm looking for historical tidbits. > > agt Well, you have to read for example the mentioned Lisp Machine Window System Manual (available as PDF). On page 2 there is a 'Note from Richard Stallman', where he writes in what is clearly his style: "The current implementation of the window system is based on flavors, and was designed and implemented primarily by Howard Cannon and Mike McMahon during 1980. It replaced an earlier version implemented by me, which was based on Smalltalk-like classes. The newer system is generally an improvement, but as Howard Cannon steadfastly refused to discuss the design with me I must decline responsibility for such counterintuitive aspects as the definition of exposure." -- http://lispm.dyndns.org/
From: George Neuner on 6 May 2008 17:12 On 05 May 2008 03:06:50 -0400, Kent M Pitman <pitman(a)nhplace.com> wrote: >Ken Tilton <kennytilton(a)optonline.net> writes: > >> George Neuner wrote: >> > Conceptually, closures create a parameterized instance of a function >> > by capturing the values of the function's free variables. >> >> Not sure this matters, but it is not just the values being captured, >> it is the variables themselves, for I can assign to them and might >> share them with other closures. > >The point you make is valid, but I'm not sure if it matters either, >but mostly only because Xah's writing is just so hard to read that >it's hard to tell WHAT is relevant. > >It saddens me actually, because it sounds like he actually thinks >about a bunch of issues, and has a lot of energy that is frittered >away in unproductive fashion. I think it's very hard for people to >agree with him when they can't tell what he's saying--at least, I >can't. I think he sometimes covers for less strong English >composition skills by smokescreens built of personality flair, but >he'd benefit from some honest self-reflection on whether confronting >the communication problem more directly wouldn't help him. I don't >think people would mind talking to him as much if he were less >flippant about the fact that he's just plain unintelligible a lot, and >less willing to blame that on other people. > >In the end, people fail to agree with him, and he mistakes that for >them disagreeing with him, which is a subtle wording difference, but >not at all the same thing in practice. And he often appears sure that >what he MEANS is right, which it might be, for all I can tell. If he >can't express it well enough to tell, though, it's hard to go much >farther. I agree. My impression is that Xah is very intelligent. It seems that he is largely self educated - which I normally consider a plus provided the learning is sufficiently comprehensive. I generally like people who love to learn. But being intelligent does not mean that he has, in his own words, "penetrating insight" into whatever he happens to be thinking about. Glancing through his web page, it seems to me that he is struggling to understand many CS concepts and is annoyed that he is finding it difficult. He appears to have an almost pathological hatred of jargon and to be convinced that jargon is meant to exclude people from the club rather than to efficiently convey ideas. I could be completely wrong in my impressions, but Xah's language is sometimes unclear and I am left to guess whether he really understands what he is talking about. >To the point in this thread, he's made some remarks about global >variables that may be reasoned or may not, but that are certainly not >clearly enough presented to know what in fact he is saying. Then he >makes fun of and offers active annoyance at people who've gone out of >their way to engage him rather than dismiss him, trying to ferret out >what he might be saying. > >His remarks on closures vs object-oriented systems might be general >confusion about what happens presently, or might just be speaking >abstractly about concepts, and in the latter situation, might or might >not be reasonable observations. It's just hard to tell. It is obvious that he has put some thought into the subject, and now that he's clarified earlier remarks, it's also clear that he has a rudimentary understanding of the concept - albeit from a theoretical point of view rather than a practical one. But it is also seems that he lacks sufficient understanding of programming semantics to fully appreciate why his simple mental model isn't workable. >To Kenny's comment above, the relevance seems to be that > (defun foo (x) y) >means more than > (subst <some-value> 'y '(defun foo (x) y)) >but indeed means that should y be given a new value through program >execution, foo will see that new value. I'm pretty sure that Xah as >much as said this. Kenny was actually replying to me [George] because I said "value" instead of the technically correct "binding". That particular detail though was irrelevant to the point I was making about parameterizing functions. >I couldn't figure out what the __ stuff was about. It might have been >a restatement of the *...* idea. Or it might have been saying that a >closure was only ever used like: > (defun foo (y) (setq x y)) > (defun bar () x) > (list (foo 3) (bar) (foo 4) (bar)) > => (3 3 4 4) >and that globals would live in __x and that other variables would be >created locally, as if in the FOO definition above, the x would be created >locally to FOO, not globally, because it had no special marker saying he >wanted the global variable, as if it meant > (defun foo (y) > (let ((x y)) > x)) >but then again... he might not have meant that. His writing doesn't allow >me to tell. > >It's an open question whether he can tell whether > (defun foo (x) (lambda () x)) >gives a function where the x storage location is new each time foo is >called, because at least one reading of his writing is that he thinks >the free x in (lambda () x) might somehow [as a closure variable] refer >to some __x secret global place that variables get put. This would be kind >of like a weird gosub kind of thing I think I've seen in some old BASIC >variants where function arguments weren't really "bound" but were rather >names of global variables to set on entry to the function, so that >defining > (defun foo (x) (+ x 3)) > (defun bar () (foo 4)) >and then calling > (bar) >was really the same as writing: > (defun foo () (+ __x 3)) > (defun bar () (setq __x 4) (foo)) > (bar) >I don't think this is what Xah means, mostly because I think he's >smarter than to think this. But his wording is vague enough that I >think it would support some odd readings in this area. And under this >reading, he'd be missing the point that (defun foo (x) (lambda () x)) >means that (foo 3) and (foo 3) actually return closures over a different >x, not over a common x. I got the gist of it - pseudo-privacy using a naming convention to segment the global variable space. Very familiar from my days of embedded C programming. However, my (maybe wrong) impression was that he was thinking along the lines of providing static locals as in C and did not realize that a) multiple closures can share a source function, b) each closure is a unique parameterization instance of the source function, and c) that the private variables need to be per closure rather than per source function. From his latest post, it seems like he maybe has realized some of this. It's unclear to me whether he actually understood it from the beginning. >I will say that many years back, I was talking to Bob Kerns (RWK) when >we were both working at Symbolics [he and I also worked together at >MIT and he taught me a great deal about Lisp in my formative years] >and the topic of the day was a function called dw:accept-2 or >something like that, I'm not sure I'm remembering the name right... it >was part of the internals of the accept substrate of Dynamic >Windows. He had identified it as the largest single function >definition in Symbolics Genera. It had clearly gotten out of hand. >He said to me that if he had it to do over again, he'd have written it >as a flavor [i.e., a "class" in CLOS terminology; DW was written in >Zetalisp, which was based on Flavors--probably New Flavors by the time >of this discussion, but it was the same basic idea]. This took me >aback because I had never clearly understood that a closure was really >just a vague kind of anonymous, opaque class. Probably I should have >noticed this ages before, since I had at that point been programming >in CL for 10 years or so, but I hadn't ever really thought about it in >such concrete terms. I understood instantly what he was saying, >though, and it was quite an epiphany. It would never have occurred to >me to rewrite something involving closures as something involving >flavors/classes, but it seemed obviously right when he mentioned it. > >Closures offer variables that hold (as Xah seems to be alluding to, if >I can understand what he's running on about) state. And classes have >the additional feature that the state is more "out in the open", if >you will, especially since in CL one can always get in and use >WITH-SLOTS [as opposed to languages like Java and C# where you can >find yourself "locked out" of your class if you were not there at time >of definition and didn't make something public. I had the vaguest >sense that Xah was using the term "closed" to mean "encapsulated", and >if you make this relation between closures and classes, then you can >sort of see the analogy, even though it is syntactically different >than how Lisp texts usually talk about it. So maybe this is the >observation that Xah is making. Or maybe it's related. Or maybe not. >Who can tell? It's a pity. > >As a matter of practice, one cannot credit another with being right in >an academic or technical discussion merely because they have said >something vague and that vague thing is not inconsistent with an >epiphany. If one could get such credit, then I would say things like >"We need to invent a better power supply." and then claim credit for >solving a major piece of the climate change problem, while meanwhile >just chiding people all along for not understanding the detail of my >remark... The credit goes to the first person to describe how to do >that in a clear manner that can be executed upon unambiguously by more >than one person working in isolation, not to the first person who says >something so vague that it merely spans the relevant problem space. > >But what's a worse pity is that Xah can't acknowledge others' attempts >to engage him for what those attempts are--a friendly act. He seems to >feel compelled to bat back the very people who are doing the most work >to treat him like a human being. Much more than he sometimes gives >the impression he's doing for them. I fully expect he'll explain to >me why I'm a loser for writing this piece, which is intended not to >make him feel bad, but rather to encourage him to take constructive >action that would improve his overall ability to interact with the >community constructively. All of this just my personal opinion, of >course. Your (and his) mileage may vary. Ah well. At least I tried. I think we probably could all cut Xah some slack provided he stops the rude name-calling. George -- for email reply remove "/" from address
From: Aaron Brown on 6 May 2008 01:36
Xah Lee wrote: > If you could, put out a snippet of code of closure, in > emacs lisp. I'll show how it is done with global vars. There are some here, using the CL package's lexical-let macro: http://www.delorie.com/gnu/docs/emacs/cl_21.html -- Aaron http://arundelo.com/ |