|
Prev: You want abbreviations? You can't handle abbreviations!
Next: Hot Shop Audemars Piguet Royal Oak Watches - Audemars Piguet Minimum Price
From: Pascal J. Bourguignon on 6 May 2008 03:46 "xahlee(a)gmail.com" <xahlee(a)gmail.com> writes: > Dear Stefan and all, > > If you could, put out a snippet of code of closure, in emacs lisp. > I'll show how it is done with global vars. emacs lisp has no closure. lexical-let simulate closures in emacs lisp, but not using global variables! It does so by creating symbols on the heap. lexical-let could have just used structures to do the same. Instead of: (macroexpand '(lexical-let ((x n)) (lambda (y) (+ x y)))) --> (let ((--cl-x-- (make-symbol "--x--"))) (setf (symbol-value --cl-x--) n) (list (quote lambda) (quote (&rest --cl-rest--)) (list (quote apply) (function (lambda (G84404 y) (+ (symbol-value G84404) y))) (list (quote quote) --cl-x--) (quote --cl-rest--)))) we could have: --> (defstruct variable value) (let ((--cl-x-- (make-variable))) (setf (variable-value --cl-x--) n) (list (quote lambda) (quote (&rest --cl-rest--)) (list (quote apply) (function (lambda (G84404 y) (+ (variable-value G84404) y))) (list (quote quote) --cl-x--) (quote --cl-rest--)))) Which shows that there's nothing related to global variable in there. These symbols just cannot name global variables, because if they did, you'd get collisions and conflate closure variables into a single global variable! if --cl-x-- named a global variable, this would be wrong: (list (lexical-let ((x 1)) (lambda (y) (+ x y))) (lexical-let ((x 2)) (lambda (y) (+ x y)))) since both closure in the list would add 2 to their argument! To implement closures you just cannot use global variables. > Common Lisp is fine but i don't know Common Lisp. Perhaps you should learn it... > For good or bad, i'd like to reiterate here: folks, closures are > effectively just function using global vars. This, is the most clear > statement capturing the heart of closure, and illustrating it in a > background practically all modern computer languages can understand. You just don't know what a closure is, and you just don't know what a global variable is either. This is frightening. > What you guys are saying, are technical details. One social way to see > this is that, effectively the closure is used in lisp community only. > Outside, may it be bash, perl, python, javascript, Java, Haskell, > Mathematica, the term is effectively unknown. Not that these languages > doesn't have the power of closure builtin, just that the term is > foreign. Why? Precisely because only the Lisp languages, define or > implement them in particular way, and call it Closure. No. That's because Common Lisp talks about real hard physical fact of life, while the other programming languages are toys from DisneyLand. Saying that closures are done with globals, is like saying that Mickey and Minie never had sex (or actually like saying that Mickey's brother or sister never had sex despite of Mickey's nephews). It's possible, but only in DisneyLand. > Stefan Nobis <sno...(a)gmx.de> wrote: > �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). ...� > > Yeah. Now, that accompanying env, can be the global env. One just need > to partition it so as to become several envs with a identification > scheme. One simple to illustrate way, is by tagging id to the var > names. (folks, was this so hard to understand? was this so deep a > concept that required me like 5 painful messages in heavy competition > to finially clarify? Recall, Rainer began, by called me FUD! That's > FEAR, UNCERTAINTY, and DOUUUUUUUBT!!!) And that's where you don't have global variables anymore! Once Mickey has sex, it's not DisneyLand anymore! It's real life. > What are OOP's Jargons and Complexities > http://xahlee.org/Periodic_dosage_dir/t2/oop.html Yes, we know that you prefer Disney literature to scientific papers. Good luck dealing with the world with these ideas! -- __Pascal Bourguignon__
From: Didier Verna on 6 May 2008 03:57 "xahlee(a)gmail.com" <xahlee(a)gmail.com> wrote: > Dear Stefan and all, > > If you could, put out a snippet of code of closure, in emacs lisp. > I'll show how it is done with global vars. Emacs Lisp is probably the worst Lisp dialect ever. You shouldn't try to learn Lisp from Emacs Lisp. To answer your question: have a look at the macro lexical-let in cl-macs.el. > For good or bad, i'd like to reiterate here: folks, closures are > effectively just function using global vars. Again, that is meaningless. Define "using". Define "global" (seems quite different from what a global var actually is). -- 5th European Lisp Workshop at ECOOP 2008, July 7: http://elw.bknr.net/2008/ Didier Verna, didier(a)lrde.epita.fr, http://www.lrde.epita.fr/~didier EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (0)1 44 08 01 85 94276 Le Kremlin-Bic�tre, France Fax.+33 (0)1 53 14 59 22 didier(a)xemacs.org
From: viper-2 on 6 May 2008 11:14 On May 6, 3:57 am, Didier Verna <did...(a)xemacs.org> wrote: > "xah...(a)gmail.com" <xah...(a)gmail.com> wrote: > > Dear Stefan and all, > > > If you could, put out a snippet of code of closure, in emacs lisp. > > I'll show how it is done with global vars. > > Emacs Lisp is probably the worst Lisp dialect ever. On the contrary, Emacs Lisp (Elisp) works very well for its constitutents who use the dialect as it was intended - primarily to customize and extend "the extensible, customizable, self-documenting, real-time display editor" Emacs. Xah, Elisp is not a Common Lisp, so one cannot hope to master Common Lisp using Elisp as the programming tool. Elisp uses dynamic and not lexical scope, and has no obect system. The fundamental goal of cllers is mastery of Common Lisp. Discussions of a more philosophical content may be interesting from time to time, but are tangential to the real effort of honing skills in Common Lisp.To do the latter one has to translate from philosophical abstractions to real code. The problem night be much like expecting to master the piano while confining practice to scales representing the theory of musical intervals (http://xahlee.org/UnixResource_dir/writ/ piano_scale.html). At some point one has to practice compositions - musical code - in order to learn. What you need to do is download a reasonable implementation of Common Lisp, get a good text or two and write code, code, code. One can see that you are smart, but referring to cllers as "morons", or using the "frack" word indiscriminately, is not likely to encourage positive responses. Good luck. agt
From: Didier Verna on 6 May 2008 12:14 viper-2 <visionat(a)mail.infochan.com> wrote: > On May 6, 3:57 am, Didier Verna <did...(a)xemacs.org> wrote: >> >> Emacs Lisp is probably the worst Lisp dialect ever. > > On the contrary, Emacs Lisp (Elisp) works very well for its > constitutents who use the dialect as it was intended - primarily to > customize and extend "the extensible, customizable, self-documenting, > real-time display editor" Emacs. You have got to be kidding me. I don't see how being dynamically scoped by default helps you in any way (even in a self-blah-blah editor in which user options could simply be defined in terms of CL's defparameter). I don't see how not having lexical scope helps you in any way either. On the other hand, I (among others) maintain XEmacs, Gnus, BBDB, and a few packages of my own, and I can tell you how I wish Emacs Lisp had CLOS, or simply were just Common-Lisp in the first place. BTW, what exactly do you mean by "customize and extend [...]" ? Today, XEmacs has 30% (~ 150000 lines) of its code base written in elisp; Gnus alone amounts to 140000 lines, and I'm not even speaking of XEmacs'SUMO tarballs (the whole external libraries shipped as packages). I wouldn't call elisp an "extension language" anymore. -- 5th European Lisp Workshop at ECOOP 2008, July 7: http://elw.bknr.net/2008/ Didier Verna, didier(a)lrde.epita.fr, http://www.lrde.epita.fr/~didier EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (0)1 44 08 01 85 94276 Le Kremlin-Bic�tre, France Fax.+33 (0)1 53 14 59 22 didier(a)xemacs.org
From: Don Geddis on 6 May 2008 12:52
"xahlee(a)gmail.com" <xahlee(a)gmail.com> wrote on Sun, 4 May 2008 : > If there are 4 lisp programers, most or all of which i think are > experienced, and all claim that i was wrong, how can i be right? At the very least, you ought to more seriously consider the possibility that you are wrong. > I'm guessing my problem has to do with my personality. A normal person, > would probably just discuss the issue in earnest. Like, we all human > beings, some knows some areas better, and we all make mistakes. A > discussion can just carry on in its course, and everyone can just learn > something or simply enjoy the conversation. But Noooo! I can't be like > that. That does sound like a problem with your personality, just as you suspected. Perhaps you'd make more progress if you'd work on this particular problem. > Still, it troubles me deeply, how could a patently simple explanation, a > simple concept, a penetrating view, be not clearly grasped by a gaggle of > lispers? In this thread, there are 15 messages. Not one reply, seems to > indicate that what i said is correct. Almost half of them actually pointed > out that i was incorrect, and even unhelpful. I'm greatly troubled by > this. If it happened that you _were_ wrong, what kind of evidence do you think you might see? I'm curious why you don't at least think about the case where you are not correct. Might that explain all the reactions you're getting? > i'm rather quite surprised how my exposition of the closure concept > turn up so many messages, many claiming it being even unhelpful or > useless. If your theories of the world are constantly surprised by actual observations of that world, at some point you need to consider that perhaps your theories are in error. After all, the whole point of a theory is to make what happens later predictable, not surprising. -- Don _______________________________________________________________________________ Don Geddis http://don.geddis.org/ don(a)geddis.org Christian: One who believes that the New Testament is a divinely inspired book admirably suited to the spiritual needs of his neighbor. One who follows the teachings of Christ in so far as they are not inconsistent with a life of sin. -- Ambrose Bierce, The Devil's Dictionary |