In article <010520031615039580%nos...@iam.invalid>, Mark Conrad wrote: > In article <m3n0i6k8wz....@javamonkey.com>, Peter Seibel ><pe...@javamonkey.com> wrote:
>> > Is relying on "define-symbol-macro" going to get me into trouble down >> > the road, in your estimation.
>> I'd say yes. Until you get a deeper understanding of what macros, >> variables, closures, etc. actually are. I'd reiterate the point >> someone made a couple weeks ago--learn Lisp. Use it the way it was >> intended to be used. Get it under your fingers.
> So far as learning Lisp from books is concerned, I have not had any > luck resolving issues like the ones we are discussing here.
It seems you have made up your mind in advance what is useful and what is not, and you only accept from books information that confirms your prejudices.
> In other words, there are things that can only be learned by asking > specific questions in NG's like this one.
People in the newsgroup are able to react to your prejudices in ways that books can't. This says more about your mental incapacity than about the usefulness of the newsgroup as a learning tool.
In article <86fznyurn4....@bogomips.optonline.net>, Marc Spitzer
<mspit...@optonline.net> wrote: > > They correct me, and I learn.
> Well just consider this another correction.
I do, thanks for taking the time and effort.
I can see be the general tone of the responses lately that I have worn out my welcome here.
Thanks to all here for helping me learn, I appreciated it immensely.
I would have liked to continue, but that does not seem possible because my preferred method of learning tends to infuriate people here.
I noted that there was one side thread where the poster wrote that he gained valuable insite from the posts in _this_ thread, so I feel somewhat vindicated by my "fool's-approach" to acquiring knowledge.
Cool down fellas, and remember:
Old CL newbie fools never die, they just f-a-a-a-d-e away.
Mark Conrad <nos...@iam.invalid> writes: > In article <86fznyurn4....@bogomips.optonline.net>, Marc Spitzer > <mspit...@optonline.net> wrote:
> > > They correct me, and I learn.
> > Well just consider this another correction.
> I do, thanks for taking the time and effort.
> I can see be the general tone of the responses lately that I have worn > out my welcome here.
> Thanks to all here for helping me learn, I appreciated it immensely.
> I would have liked to continue, but that does not seem possible because > my preferred method of learning tends to infuriate people here.
In all honesty you would have no problem staying here iff you changed one thing in your preferred method of learning, stop assuming you are right when you do not know what you are talking about. If you are truly trying to learn something then you only need to be corrected once on any given point, look at your continuations thread for a counter example.
> I noted that there was one side thread where the poster wrote that he > gained valuable insite from the posts in _this_ thread, so I feel > somewhat vindicated by my "fool's-approach" to acquiring knowledge.
That is besides the point, your preferred method is designed to piss people off and this is counter productive from you POV as someone who want to learn something. You may get a better response from c.l.python or c.l.perl because you have more people to piss off until you can not get any more help, but it is still daft to do this.
Gareth McCaughan <Gareth.McCaug...@pobox.com> writes: > (I'm not as convinced as some people here that it's > a very bad way to learn. There's something to be said > for jumping in at the deep end, and there's a lot to > be said for learning by doing something that motivates > you. But you have to be aware that you're running the > risk of annoying the people you depend on for help > so much that they give up...)
It's not a bad way to learn, provided you have a tutor who is willing to go along with it. I once tutored someone in math, who, despite getting straight C's in high school math, had semi-grandiose theories about how math worked, which he would explain to me. This approach paid off, and he ended out getting a good score on his Math SAT. However, this *only* works if you have a tutor who's willing to go along with it (the OP seems to need repetition). Otherwise, it's simply antisocial behavior.
-- /|_ .-----------------------. ,' .\ / | No to Imperialist war | ,--' _,' | Wage class war! | / / `-----------------------' ( -. | | ) | (`-. '--.) `. )----'
In article <861xzh4oew....@bogomips.optonline.net>, Marc Spitzer
<mspit...@optonline.net> wrote: > ...<snipped>...is designed to piss people off...<snipped>...
A dangling point remains to be addressed before I leave this NG.
Thanks to the unknown poster who contributed code below: *********************************************
* Mark Conrad wrote: > Now if "closure???" looks like a duck, sounds like a duck, and waddles > like a duck, as far as I am concerned it is a duck.
But it doesn't, does it? Try this:
(let ((x 1)) (defun x () x) (defun set-x (new) (setf x new))) *********************************************
Running his code in MCL ver' 4.3 ? (x) 1 ? (set-x 3) 3 ? (x) 3 ?
At the very least, this is unexpected behavior. It is yet another exception to the general behavior of CL that has to be memorized and allowed for so it won't bite me later.
Lisp gurus somehow learn the exceptions to general rules, (as those rules are laid down in the books), but the only way I had to learn about the nasty behavior above was to make a rash statement about how I thought the cookie crumbled, then sit back and wait for agreement or disagreement to my rash statement.
At the worst, something is broken somewhere in the CL implementation or in the CL hyperspec, and should be changed.
Contrast that posters example with my variation below which runs as it should run.
(defvar a) (defvar b)
(let ((x 'value-of-lexical-x) (y 'value-of-lexical-y)) (setq a x) (setq b y) (setq x 'screwed-up-value-of-lexical-x) (setq y 'screwed-up-value-of-lexical-y) (values))
? a VALUE-OF-LEXICAL-X
? b VALUE-OF-LEXICAL-Y
Now let's make small changes in my above code to demonstrate the unexpected nasty behavior, nasty behavior that is *not* explained in any of the books that have been recommended to me in this NG.
(defvar a) (defvar b)
(let ((x 'value-of-lexical-x) (y 'value-of-lexical-y)) (setq a #'(lambda () x)) (setq b #'(lambda () y)) (setq x 'screwed-up-value-of-lexical-x) (setq y 'screwed-up-value-of-lexical-y) (values))
? (funcall a) SCREWED-UP-VALUE-OF-LEXICAL-X
? (funcall b) SCREWED-UP-VALUE-OF-LEXICAL-Y
I don't want to "piss people off" so this will likely be my last post in this NG.
I can see now why there are so few new newbies adopting CL as their preferred language, when it is apparent how cantankerous and downright ornery people are in this NG.
Mark Conrad <nos...@iam.invalid> wrote: > At the very least, this is unexpected behavior. It is yet another > exception to the general behavior of CL that has to be memorized and > allowed for so it won't bite me later.
No! This means that you do not understand what bindings, closures or object identity mean. You know the words and have some mental constructs about them, but *they are wrong*. Do yourself a favor and read SICP. From the beginning. You may even learn something.
* Mark Conrad wrote: > At the very least, this is unexpected behavior. It is yet another > exception to the general behavior of CL that has to be memorized and > allowed for so it won't bite me later.
Of course it isn't. This *is* the general behaviour. As people have repeatedly said, closures capture *bindings*, not values Lexical bindings in Common Lisp have lexical scope and indefinite extent, and are mutable. I don't think you understand what a closure is at all.
I must admit to being rather confused now though. At some point earlier in the thread you were enthusing about wanting to do everything with continuations and complaining that it was a deficiency that CL didn't have call/cc.
Well, one fairly common view of continuations (and, I expect, how they would appear in a CL which did have them), is that they are simply the generalisation of closures to include block names and possibly other control points, which currently have lexical scope and dynamic extent, to have lexical scope and indefinite extent.
How can you want call/cc and *not* understand what a lexical closure is? Do you actually have any *idea* what a continuation is, or are you just repeating some magic phrase that you read?
Incidentally I liked this:
> At the worst, something is broken somewhere in the CL implementation > or in the CL hyperspec, and should be changed.
> At the very least, this is unexpected behavior. It is yet another > exception to the general behavior of CL that has to be memorized and > allowed for so it won't bite me later.
How so? It's *exactly* the expected behaviour. This is precisely what closures are about. What general behaviour do you think it's an exception to? What is it about this behaviour that makes you call it "nasty" later on?
> Now let's make small changes in my above code to demonstrate the > unexpected nasty behavior, nasty behavior that is *not* explained in > any of the books that have been recommended to me in this NG.
> (defvar a) > (defvar b)
> (let ((x 'value-of-lexical-x) (y 'value-of-lexical-y)) > (setq a #'(lambda () x)) > (setq b #'(lambda () y)) > (setq x 'screwed-up-value-of-lexical-x) > (setq y 'screwed-up-value-of-lexical-y) > (values))
> ? (funcall a) > SCREWED-UP-VALUE-OF-LEXICAL-X
> ? (funcall b) > SCREWED-UP-VALUE-OF-LEXICAL-Y
Why's it nasty? I'd ask "why's it unexplained?", but that's not really the right question. The right question is: What is it you think you know that makes it *require* explanation?
I'm not asking just out of curiosity, by the way. I'd like to explain, but I don't see how to explain until I know what it is that needs explaining. Maybe this potted summary will help in the interim:
It's common to say that (1) a closure is a function plus its environment, and (2) an environment is a mapping from names to values. In fact, I've said both those things several times myself. But #2 may be misleading, because an environment is a *changeable* mapping from names to values. It might be better to call it a mapping from names to *value-holders*, or, more simply, to variables. So, when you say
you have created new variables X and Y. They're visible only within the scope of the LET (unless X or Y has been declared special, of course). But they're real variables, and they continue to exist after the LET form has finished being processed.
Now, the things you've put into A and B inside the LET form are closures: each is a function plus (a reference to) its environment. That environment consists of the bindings of X and Y. Note: the *bindings*, not the *values*. If you change what X and Y are bound to, that change is visible to the closures in A and B.
Which is exactly what happens when you do the third and fourth SETQs. The closures in A and B still refer to the same variables X and Y, but now the values of those variables have changed.
You obviously find this nasty, but I don't know why. Here's an example of somewhere where it might be useful. The MAPHASH function calls a user-supplied function for each (key, value) pair in a hash table. So you can do things like this:
Notice that what you're passing into MAPHASH is a closure that needs to be able to alter BORING-KEYS.
As it happens, you can do that without closures with either LOOP or WITH-HASH-TABLE-ITERATOR. So here's another example. Suppose you're doing some kind of mathematical computing; numerical integration, perhaps. You have a bunch of algorithms you've been developing for adaptive quadrature (i.e., calculating integrals to a prescribed level of accuracy, working out what function evaluations they need to do to achieve that accuracy) and you want to see how they compare. Then:
- You can count the number of times one of the algorithms evaluates the function, like this:
All this without having to make any change to the code of the integrators or the integrand functions. And this *requires* the ability to alter variables you've closed over. You call that "nasty", but it isn't nasty; it's at least half of the point.
> I don't want to "piss people off" so this will likely be my last post > in this NG.
If you want to answer my questions above by e-mail, feel free. But I doubt answering them in c.l.l will piss anyone off very much.
> I can see now why there are so few new newbies adopting CL as their > preferred language, when it is apparent how cantankerous and downright > ornery people are in this NG.
I think you'd find much less cantankerousness if you didn't assume that whenever CL doesn't behave the way you expect it to that indicates something broken with either CL or the books you're reading. You'd learn faster, too :-).
-- Gareth McCaughan Gareth.McCaug...@pobox.com .sig under construc
> At the very least, this is unexpected behavior. It is yet another > exception to the general behavior of CL that has to be memorized and > allowed for so it won't bite me later.
> Lisp gurus somehow learn the exceptions to general rules, (as those > rules are laid down in the books), but the only way I had to learn > about the nasty behavior above was to make a rash statement about > how I thought the cookie crumbled, then sit back and wait for > agreement or disagreement to my rash statement.
Your comment that this is unexpected is fine. It is discoveries like this that were the bait that caught me when I first started with Lisp.
But it isn't an exception to the general behavior. It is a new idea. It goes along with Lisp. This is how closures work. It's not nasty behavior. It's wonderful. It's part of the underlying stratum of object-oriented programming.
If you like continuations how can you not like this?
> I don't want to "piss people off" so this will likely be my last > post in this NG.
> I can see now why there are so few new newbies adopting CL as their > preferred language, when it is apparent how cantankerous and > downright ornery people are in this NG.
Well, you could just try to roll with the punches and figure out what is pissing people off, and do a little less of it.
Most people in this newsgroup have at least a bit of the language evangelist in them, and if you stay good humored you can probably do fine. There is kind of an expectation that eventually you'll graduate beyond newbie-hood, but I'm sure you haven't worn out your welcome yet. Honestly, even if you post things people think are nonsense you will always find those ready to rise up in anger to smite you, and you could even glean information from that.
-- Fred Gilham gil...@csl.sri.com Jordan Hubbard: We have a crash bug. It needs to be fixed. We DO NOT need to know how to print 3000 spaces in 11 different languages! :-) Daniel Sobral: I concur. But if anyone wants to do it with loader, : 3kbl 3000 0 do bl emit loop ; 3kbl will do the trick.
> At the very least, this is unexpected behavior. It is yet another > exception to the general behavior of CL that has to be memorized and > allowed for so it won't bite me later.
> Lisp gurus somehow learn the exceptions to general rules, (as those rules are > laid down in the books), but the only way I had to learn about the nasty > behavior above was to make a rash statement about how I thought the cookie > crumbled, then sit back and wait for agreement or disagreement to my rash > statement.
Okay. Since it seems to require at least 5 people yelling at you to get any point through, here is my contribution:
******************************** What you demonstrate IS the general and expected behavior. You do not understand anything about how closures work in Common Lisp. Stop telling us that we are wrong and learn how they actually do work.
How is it that everyone else seems to understand these concepts? Have you even begun to think that maybe... just maybe... you are doing something wrong? And this has nothing to do with learning methods, this has to do with LISTENING and UNDERSTANDING what people say. Your learning level is on par with a 3-year old, right now. ********************************
Calling (X) returns the value of evaluating that variable binding, giving you 1.
Calling (SET-X 2) modifies the binding of X so that it now is BOUND to 2.
X -----> 2
Now, calling (X) returns the value of evaluating the variable binding named X. Can you guess what happens?
I better spell it out: it returns 2.
Stop futzing with continuations, and get your easy semantics down pat first. You are trying to do calculus without being able to add, much less anything else.
-- ; Matthew Danish <mdan...@andrew.cmu.edu> ; OpenPGP public key: C24B6010 on keyring.debian.org ; Signed or encrypted mail welcome. ; "There is no dark side of the moon really; matter of fact, it's all dark."
Mark Conrad wrote: > I can see now why there are so few new newbies adopting CL as their > preferred language, when it is apparent how cantankerous and downright > ornery people are in this NG.
The word you are looking for is "savages".
--
kenny tilton clinisys, inc http://www.tilton-technology.com/ --------------------------------------------------------------- "Everything is a cell." -- Alan Kay
In article <u7k7d8hqe8....@snapdragon.csl.sri.com>, Fred Gilham
<gil...@snapdragon.csl.sri.com> wrote: > Backing up a little, Mark wrote:
...lotsa stuff, some of it wrong...
Now why can't everyone in this NG be as non-judgemental as you are.
Very fine post you crafted, gentle nudges and suggestions, makes me actually enjoy learning this CL stuff.
Up until Gareth's post, I used to think both these terms meant the same thing.
"The binding of x is 5"
"The value of x is 5"
I completely missed the distinctions between the terms while reading about closures in my books, and the connection between the words "binding" and "environment", which proved to be my downfall and led to me making foolish statements about how the cookie crumbled.
Gareth came to my rescue, explaining that "binding" and "value" are two seperate and completely different things.
Once I was alerted to that, everything else fell into place.
Before today I could not spell "expert".
Now I are an expert on closures ;-)
Anyhow, at least now I know a little bit more about them.
About the difference between 'binding' and 'value' - In retrospect, I can't believe I was blind-sided by such an obvious ommission from my store of knowledge.
Wonder what else I have screwy ideas about.
Hmm, time for me to make more rash statements about how I believe the cookie crumbles.
In article <slrnbb5ses.on.Gareth.McCaug...@g.local>, Gareth McCaughan
<Gareth.McCaug...@pobox.com> wrote: > ...<snipped>...environment consists of the bindings of X and Y. > Note: the bindings, not the values.
Thank you, thank you, you are the first person who raised my awareness that there was a _difference_ between bindings and values.
Oh, I read the prattle in the books about bindings, then more prattle about values, but _nothing_ in those books about a binding being different than a value.
Up until now, I thought that saying "the value of x is 5" was exactly the same as saying "the binding of x is 5".
Thanks to your post, I now realize that "binding" and "value" are two seperate and distinct things.
After reading your post, I did some experimenting:
? (let (x) (setq x 5) x) 5
The (x) in the let-form above creates a "binding" for x. (whatever the heck a "binding" is)
The (setq x 5) creates a "value" for x.
To elaborate a bit, let's make a slightly more complicated 'let'
? (let (x (y 7)) (setq x 5) (list x y)) (5 7)
The (let (x... in the let-form above creates a "binding" for x. (whatever the heck a "binding" is)
The (setq x 5) creates a "value" for x, a separate operation from creating the "binding" for x.
The (y 7) creates a binding *and* a value for y.
Now, thanks to you, and no thanks to the %*#&*! books, I *finally* have a clear idea of what a "closure" is.
Back to the book, I gotta find find out what earthly reason there is for seperating "binding" from "value", other than to confuse newbies.
Needless to say, your post gets saved to my Extremely-Valuable-Posts file.
Mark Conrad <nos...@iam.invalid> writes: > I don't want to "piss people off" so this will likely be my last post > in this NG.
> I can see now why there are so few new newbies adopting CL as their > preferred language, when it is apparent how cantankerous and downright > ornery people are in this NG.
> Mark-
People in this newsgroup only get cantankerous when a newbie comes into the group and throws his/her weight around on the strength of (possibly) wide experience in other languages. It is necessary for newbies to be quiet and pay close attention to the language until they being to understand it from the standpoint of actual, non-trivial use. Its great to ask questions about the language, but you mustn't presume to know how the language <should> be. Common Lisp isn't perfect, but once you learn it (and by doing so, unlearning and properly relearning techniques and language characteristics you've long thought cast in stone), then you'll begin to appreciate how nice it really is.
I think if you spend 6 months really trying to learn Common Lisp, by writing programs, then you'll find yourself starting to write Lisp in other languages too. I didn't really start to perceive some of the subtlties of C/C++ (such as they are) until I began a serious approach to Common Lisp.
Mark Conrad <nos...@iam.invalid> writes: > Thanks to your post, I now realize that "binding" and "value" are two > seperate and distinct things.
but you don't yet understand their relationship:
> After reading your post, I did some experimenting:
> ? (let (x) (setq x 5) x) > 5
> The (x) in the let-form above creates a "binding" for x. > (whatever the heck a "binding" is)
> The (setq x 5) creates a "value" for x.
binding is sight, and like sight, is constrained by who is looking and where/when/how/why they look. value is what is perceived given this complicated process of looking.
here, `let' creates a small telescope (we are one end, `x' the other), `setq' moves the telescope. the 5 has always been there (how could it not be?); moving the telescope in its direction does not create it. what is created is our awareness of it, through the `x'.
that is why "the truth is out there" is not a bad approach to mass-market functional conspiracy programming... (end lame joke).
In article <020520031940504126%nos...@iam.invalid>, Mark Conrad <nos...@iam.invalid> wrote:
> > ...<snipped>...environment consists of the bindings of X and Y. > > Note: the bindings, not the values.
> Thank you, thank you, you are the first person who raised my awareness > that there was a _difference_ between bindings and values.
> Oh, I read the prattle in the books about bindings, then more prattle > about values, but _nothing_ in those books about a binding being > different than a value.
See for example the entry for binding in the glossary section of the HyperSpec:
binding n. an association between a name and that which the name denotes. ``A lexical binding is a lexical association between a name and its value.'' When the term binding is qualified by the name of a namespace , such as ``variable'' or ``function,'' it restricts the binding to the indicated namespace, as in: `` let establishes variable bindings.'' or `` let establishes bindings of variables.''
There are goods books for beginners out there, some for free, that explain theses things. For example, take a look at http://psg.com/~dlamkins/sl/cover.html
Kenny Tilton <ktil...@nyc.rr.com> writes: > Mark Conrad wrote: > > I can see now why there are so few new newbies adopting CL as their > > preferred language, when it is apparent how cantankerous and downright > > ornery people are in this NG.
> The word you are looking for is "savages".
So he is the missionary? To the rest of the savages "Soups on"
In article <costanza-6A0E31.12442903052...@news.netcologne.de>, Pascal
Costanza <costa...@web.de> wrote: > See for example the entry for binding in the glossary section of the > HyperSpec:
> binding n. an association between a name and that which the name > denotes. ``A lexical binding is a lexical association between a name and > its value.'' When the term binding is qualified by the name of a > namespace , such as ``variable'' or ``function,'' it restricts the > binding to the indicated namespace, as in: `` let establishes variable > bindings.'' or `` let establishes bindings of variables.''
Specifically:
> '' When the term binding is qualified by the name of a > namespace , such as ``variable'' or ``function,'' it restricts the > binding to the indicated namespace, as in: `` let establishes variable > bindings.'' or `` let establishes bindings of variables.''
Is that all in the heck "binding" means. Cheez!
And I thought there was much more that "binding" meant, that influenced exactly how the variable would act in a program.
Now I see why the great majority of my Lisp books don't even mention "binding" in the index.
Okay, if I FINALLY understand binding correctly, the 'let' form below does *not* establish a binding between x and anything else!
? (let (x) x 'lexical-variable-x-is-not-bound-to-anything) LEXICAL-VARIABLE-X-IS-NOT-BOUND-TO-ANYTHING
Likewise: (defvar k)
The special variable k is not bound to anything either.
All the lousy defvar does is make a promise to the compiler, a 'declaration' to the compiler, (and to anyone who reads my code), that eventually a 'special' binding to k _will_ be created, if and when I get around to using setq to create the binding.
Likewise: When one uses the word "binding" when describing closures -
...as in "In the closure k below, lexical variable x is bound to the value BIG, and lexical variable y is bound to the value DADDY"
I am right back where I started a week ago, when I said there was no difference between saying:
" X is 'bound' to the value BIG "
- - or - -
" The value of X is BIG "
Okay, here is the closure k that I have been talking about:
(defvar k)
(let ((x 'big) (y 'daddy)) (setq k #'(lambda () (list x y) )))
? (funcall k) (BIG DADDY)
Now, where is that guy who made a statement a few days ago to the effect that a closure preserves the bindings, not the values.
To me they seem to be essentially the same thing.
Wonder what he meant?
Oh well, twenty years from now I will figure it all out.
FWIW, all SICP had about bindings was a general statement on page 184 that bindings associated values with variables.
Do it! Do it now! Take some time to read and understand these things. There are over 30 chapters in that book. You don't want to post that much as you do on every single topic, right?