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 Very likely.
Like I keep saying, JavaScript is a fairly good language let down by the DOM. If the DOM objects exposed elements sensibly, you could use JavaScript's for( in ) syntax. But they don't. So most JS programmers are forced to use C-like for() loops on objects.

That guy's iterate() function is clever because it puts a somewhat less-fiddly interface around such a loop, using a little-exploited feature of JavaScript. This is useful in a website with lots of these sort of loops.

If you've done any programming with streams or generators, the improvement is obvious.

Wade.

Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please

-- "Anything but Ordinary" by Avril Lavigne.

New Define "streams or generators"
Are they names of concepts, or one language's name for a concept I might know under a different name? Or a name for something I didn't know there was a name for?[1]

[1] There's quite a few of those, it seems. I keep asking people to explain what they mean by something, and I end up saying, "Oh, of course I do that. It's just good practice. There's a name for that?"
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New They are names of concepts, at least one analog you know
There is a fairly good introduction to them in Perl at [link|http://perl.plover.com/Stream/stream.html|http://perl.plover.c...tream/stream.html].

Put simply, a stream is an infinite stream of data from somewhere. Any amount of data you want, you have. You can implement one by having a list of data and then a function at the end that can generate as many more as you might want. Depending on who you talk to, that function might be called a promise or a generator. (The linked article calls them promises.)

The obvious analogy is a Unix pipeline. The difference is that streams and generators exist within your program, and not due to processes communicating. All of the things that you can do with pipelines translate fairly directly to streams. (And streams have other tricks as well, for instance it is easy to build a stream that merges two others, while it is hard to write that in a Unix pipleline.)

Obviously this is just a set of techniques. But it is a very powerful set of techniques to know about when you need it.

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 Giggle
So you could have code that's "on a promise", then?

</silly>


Peter
[link|http://www.ubuntulinux.org|Ubuntu Linux]
[link|http://www.kuro5hin.org|There is no K5 Cabal]
[link|http://guildenstern.dyndns.org|Home]
Use P2P for legitimate purposes!
New Yes. And you're hoping that the promises are kept. :-)
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)

I think coming back from the summit was the rather more important achievement.
86 ms