IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New I said "invocation of the function" for a reason
In that example the closure in JavaScript is bound to an internal data structure representing the call to curry_all. Therefore all of the closures created on the same call to curry_all will see the same item variable. That variable has the last value that it was assigned, which is from the last time through the loop.

I only bring it up because I got bitten by it and it took me a while to figure out what was happening. (And then to find out that it is supposed to do that according to the spec.)

As for your closure-object comparison, there is at best limited validity to that. (Yes, I've seen the same point made. And argued against it as well before.) True, a closure can be thought of as an object with only one method and no class. However conceptually this is a useless way to think, closures aren't just somewhat useless objects minus infrastructures, they're a different programming building block. With closures it is trivial to create an OO system. With OO you can't re-create closures.

If you've never used them, the difference in how you think isn't easy to communicate. About the best that I can do is to say that objects make good nouns, closures make good verbs.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New You're right about not getting it without using it
Because I haven't used closures, and I still don't "feel" the difference.

I guess all I'm really interested in knowing is whether this is something I should try to learn because it's a useful technique, or is it simply another way of doing something I'm already doing another way. I'll have to look at it some more when I've got more than five minutes at a time to think about it.
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New I'm sure that you AREN'T using closures
It doesn't really resemble any other technique that I know of.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
     Interesting iterating in JavaScript trick - (ben_tilly) - (19)
         Ooooo. I like... -NT - (FuManChu)
         Very elegant. -NT - (static) - (17)
             I must be missing something - (drewk) - (16)
                 Very likely. - (static) - (4)
                     Define "streams or generators" - (drewk) - (3)
                         They are names of concepts, at least one analog you know - (ben_tilly) - (2)
                             Giggle - (pwhysall) - (1)
                                 Yes. And you're hoping that the promises are kept. :-) -NT - (ben_tilly)
                 There are several benefits - (ben_tilly) - (10)
                     Much better - (drewk) - (5)
                         Anonymous functions and closures - (ben_tilly) - (4)
                             Looks like it's treating 'i' as a reference - (drewk) - (3)
                                 I said "invocation of the function" for a reason - (ben_tilly) - (2)
                                     You're right about not getting it without using it - (drewk) - (1)
                                         I'm sure that you AREN'T using closures - (ben_tilly)
                     Can't make your example work - (drewk) - (2)
                         I think you're missing the 'anonymous' part. - (FuManChu) - (1)
                             Got it, example works now, woot -NT - (drewk)
                     I like this one better - (tuberculosis)

"Your server tonight will be: Jim." DAMMIT!
102 ms