[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread T.J. Crowder
Hi all, Weighing in... First off, love the idea of Function#repeat. Wonderfully simple and expressive. As Tobie says, the goals when doing it should be to handle all of the issues PE already handles, to reuse existing code, and to be consistent with other API functions. Some notes: 1. I'd

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread Robert Kieffer
@TJ... Your goals sound about right. Implicit in there, I think, is make it easy to deprecate PE at some later date. At least, that's how I read it. :) Re: #2 - Why not just use bind() to provide context? I've never been a fan of overloading arguments with multiple interpretations. 'Gets

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread T.J. Crowder
Hey Robert, It's true, I was thinking in terms of deprecating PE at some stage... :-) Re #2: Using #bind at least doubles the call overhead, which I'm not a fan of generally. ...have it throw $break! Now that is a very smart idea. -- T.J. Crowder tj / crowder software / com On Aug 27, 4:13 

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread Tobie Langel
Food for thought: 1. We would like to completely decouple native and host objects in the LANG section for version 1.7. `setTimeout` and `setInterval` are host objects... 2. We're planning strict ES 5 compliance of enumerables for 1.7. that implies removing $break. Best, Tobie On Aug 27,

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread Tobie Langel
*blech* to ES5's enumerable stuff not having $break or similar functionality.  I've just read the forEach section of the draft spec from a while back, and I'm not seeing a discussion of exception handling.  I haven't delved deep, though -- do you know offhand how exceptions in the callback

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-08-27 Thread T.J. Crowder
Exceptions aren't eaten. Good, so a $break-like mechanism is possible then, just moved out a level. -- T.J. On Aug 27, 10:49 pm, Tobie Langel tobie.lan...@gmail.com wrote: *blech* to ES5's enumerable stuff not having $break or similar functionality.  I've just read the forEach section of

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-26 Thread Tobie Langel
How to stop it? arguments? Stopping it is as easy as: pe = foo.repeat(); pe.stop(); Passing arguments would require some simple currying: Function.prototype.repeat = function(interval) { var fn = this; if (arguments.length 1) { // not testsed but you get the idea fn =

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-26 Thread joe t.
Tobie, Function.prototype.repeat = function(interval) { var fn = this; if (arguments.length 1) { // not testsed but you get the idea fn = fn.curry.apply(fn, Array.prototype.slice.call(arguments, 1)); } return new PeriodicalExecuter(fn, interval); } If sticking to the PE

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...]) -- Revised from Robert's version

2009-06-25 Thread joe t.
Rick, Maybe i'm missing how that revision works, but it appears to me that your stop property doesn't actually stop the repeater. Your stop returns before further execution happens, but the timeout ID for the window still exists. What am i missing? -joe t. On Jun 24, 12:20 pm, Rick Waldron

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...]) -- Revised from Robert's version

2009-06-25 Thread Rick Waldron
Note this last revision brings back a bit more of Robert's version, it's more 50/50 now. Rick On Thu, Jun 25, 2009 at 12:53 PM, Rick Waldron waldron.r...@gmail.comwrote: You're right... It appears i copied the source in a bit hastily. After re-examining, I've revised again...

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...]) -- Revised from Robert's version

2009-06-25 Thread Rick Waldron
You're right... It appears i copied the source in a bit hastily. After re-examining, I've revised again... http://jsbin.com/ajoqu Rick On Thu, Jun 25, 2009 at 9:37 AM, joe t. thooke...@gmail.com wrote: Rick, Maybe i'm missing how that revision works, but it appears to me that your stop

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-25 Thread Rick Waldron
Thanks for the insight Tobie, definitely appreciated. Function.prototype.repeat = function(interval) { return new PeriodicalExecuter(this, interval); } How to stop it? arguments? This may come to you twice, but this is slightly updated: http://jsbin.com/opimu This repeat() method def is

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Tobie Langel
You might also want to look at the already existing PeriodicalExecuter. Any implementation of a Function#repeat API should take this in account. On Jun 24, 2:55 pm, joe t. thooke...@gmail.com wrote: Only suggestion i can think of is that your method strongly implies a requirement that

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Robert Kieffer
I can't say I'm a big fan of this. For several reasons. First, it's just a cosmetic replacement for setInterval(myfunction (...).bind(), ...) which simply isn't all that bad. Second, I'm not a fan of setInterval in general. I've seen some rather nasty behavior with calls queuing up if the

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Rick Waldron
This is fantastic feedback - thanks! On Wed, Jun 24, 2009 at 9:55 AM, Robert Kieffer bro...@gmail.com wrote: I can't say I'm a big fan of this. For several reasons. First, it's just a cosmetic replacement for setInterval(myfunction (...).bind(), ...) which simply isn't all that bad.

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Rick Waldron
I've subbed my implementation with your to do some use-case testing. I'll report back anything of interest as I go along. Rick On Wed, Jun 24, 2009 at 10:49 AM, Rick Waldron waldron.r...@gmail.comwrote: This is fantastic feedback - thanks! On Wed, Jun 24, 2009 at 9:55 AM, Robert Kieffer

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...]) -- Revised from Robert's version

2009-06-24 Thread Rick Waldron
I made a few modifications to your version, allowing repeat() to behave like delay() with regard to arguments I've posted a demo here: http://jsbin.com/ekone All the output is to the firebug console... i've included fbug lite just in case Rick On Wed, Jun 24, 2009 at 10:50 AM, Rick

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Tobie Langel
Just to clarify the above: Prototype Core already contains a similar functionality: PeriodicalExecuter. The API is different but the functionality is the same. I'd strongly suggest looking into combining both approaches if you want your suggestion to be included in core and not just stay a

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Robert Kieffer
FWIW, PeriodicalExecuter has always struck me as a bit of a wart on the Prototype API. The name and usage are awkward, and it's functionality really feels like something that should just be a Function extension, as we're seeing in this thread. I'm assuming it's presence is mostly a legacy thing.

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Rick Waldron
Tobie, I had in fact looked into PeriodicalExecuter and to be perfectly honest, with no offense intended, i think it's usage syntax is hideous which is what led me to writing my own Function.prototype method instead, taking inspiration from .delay() It doesnt matter to me whether or not

[Prototype-core] Re: Suggested addition to Function Methods: .repeat(seconds[, arg...])

2009-06-24 Thread Tobie Langel
Hi Rick, hi Robert. Fully agree regarding PE. It does however handle issues a regular setInterval doesn't (as you mentioned). It's clearly an area which would need refinement, but that's better done in a backwards compatible way. Personally, I'd love to see PE implemented as a method of