in reply to Re: Re: Re: Help with the concept of closures.
in thread Help with the concept of closures.

I suspect we mean different things by the word "copy".

Because lexical variables live in scratchpads and because a closure carries around the scratchpad where it was created, I say that a closure does not make a new copy of the variable.

Because a new scratchpad is created on each scope entry and the closures returned bind to the new scratchpad, you say that a closure does copy the variable.

I don't think "copy" is the right word, but I understand what you're saying and the effect is indeed accurate.

  • Comment on Re: Re: Re: Re: Help with the concept of closures.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Help with the concept of closures.
by bobn (Chaplain) on Jul 06, 2003 at 05:05 UTC

    If by "same" you mean it's the same $item it was during the life of the call to shoppingList(), even though it lives in a different scratchpad from that of all other calls to shoppingList(), then I understand what you meant. And you certainly understand what I meant. (is chromatic here the same as chromatic on slashdot? If so, I probably shouldn't argue at all.)



    --Bob Niederman, http://bob-n.com
      After some messaging, chromatic and I agree that "instance" is a better word than "copy".

      --Bob Niederman, http://bob-n.com