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.
Common Lisp is fine but i don't know Common Lisp.
------------
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.
It is just one perspective, not the only way. It isn't a correct
description if taken from the perspective of history. It isn't a
sensible description from the perspective of implementation. But from
semantic point of view, with a touch of education and pragmatics, it
is perfect.
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.
Stefan Nobis <sno...@[EMAIL PROTECTED]
> wrote:
=C2=ABA 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). ...=C2=BB
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!!!)
Effectively, a closure is just language feature that allow users to
create subroutines that works as a state machine. Alternatively, a
closure feature that would give a subroutine a paper and pen, where it
can write down values and remember it.
Global vars is one big piece of paper folks. Share!
For a good, fresh, simple, explanation of the semantic essence, of
many jargons and concepts in computing esp those associated with OOP,
see:
What are OOP's Jargons and Complexities
http://xahlee.org/Periodic_dosage_dir/t2/oop.html
Read the above, and you'll come away with a clarity, of the
mathematical essence of many jargons and concepts you hear all day,
like never before.
If nobody can show a snippet of emacs lisp code of closure for me to
tear down, then i demand 3 public posts of this content: Xah Lee is a
beautiful.
PS soliloquy to myself: gosh, i so hate tech geekers. The dumb, fat,
stupid, ugly, common, plebian, *****. Slaving around the world all
day, just to contradict me and pull me down. O, this reminds me,
Friedrich Nietzsche wrote about Master-slave morality. Yeah, the
****ing ***** of the mundane. Catch heart attack!!!!!
Xah
xah@[EMAIL PROTECTED]
http://xahlee.org/
=E2=98=84
On May 5, 8:01 am, Stefan Nobis <sno...@[EMAIL PROTECTED]
> wrote:
> "xah...@[EMAIL PROTECTED]
" <xah...@[EMAIL PROTECTED]
> 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 im****tant issue
> here is that a single function body (=3D 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.


|