Hi,

> OK so,
>
> xtimer = setTimeout( { doSomething( arg1, arg2, arg3 ); }, 500);
>
> is using the function's return?

It's calling the function right away rather than after a delay.  The
braces are incorrect (though syntactically valid).  When that line
runs, the function is called immediately, and then I _think_ the
result is thrown away and undefined is passed into setTimeout; either
that, or the function's result is passed into setTimeout, but I'm
pretty sure not.  Again, you just don't do that, so I'm not sure of
the effect of the braces.  I am sure the function is executed
immediately.

You wanted to write this:

    xtimer = setTimeout( function(){ doSomething( arg1, arg2,
arg3 ); }, 500);
                         ^^^^^^^^^^

Or even better, use the features[1] of the library we're all talking
about:

    xtimer = doSomething.delay(0.5, arg1, arg2, arg3);

I'll second Tobie's suggestion:  It's well worth your time to read up
on this stuff.  Websites, blogs, wikis, good old-fashioned books,
etc.  Here's[2] a list of suggested material in the unofficial FAQ.
Also, take an hour to read through the complete Prototype API[3]
(literally, that's all it takes to read through it, an hour).  In a
couple of months' time, you might check out Crockford's site[4] on
JavaScript (not Prototype), but probably not right now -- he gets into
advanced topics.

[1] http://prototypejs.org/api/function/delay
[2] http://proto-scripty.wikidot.com/faq#learn
[3] http://prototypejs.org/api
[4] http://javascript.crockford.com

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available



On Mar 3, 3:36 am, BearState <wixelb...@yahoo.com> wrote:
> Hi Tobie,
>
> You don't live over in Scott's Valley, do you?   Used to know a Tobie
> way back when.
>
> OK so,
>
> xtimer = setTimeout( { doSomething( arg1, arg2, arg3 ); }, 500);
>
> is using the function's return?
>
> How do I specifiy a function to setTimeout when it has args?
>
> Holy Simple Minded Idiot Batman!  It's not a timer memory leak
> problem.
>
> Riddle me this Robin ...   do you think this programmer could use some
> Bat Belt and Suspenders?
>
> Holy Mistaken Bug Identity Batman!   Definitely!
>
> BearState
>
> On Mar 2, 6:55 pm, Tobie Langel <tobie.lan...@gmail.com> wrote:
>
> > Hi again, BearState.
>
> > Your confusing different things here.
>
> > The behaviour you are describing isn't related to memory leaks at all,
> > your most probably just passing the _result_ of a function call to
> > setTimeout rather than the function itself.
>
> > In other words, if you are doing the following, you're almost
> > certainly doing something wrong (or using some very obscure functional
> > programming tricks):
>
> > setTimeout(myFunc(), 1000); // WRONG
>
> > This, on the contrary, works you're passing the function itself, not
> > the _result_ of it):
>
> > setTimeout(myFunc, 1000); // CORRECT
>
> > Anyway, if you're doing ajax requests, you should NOT be using
> > timeouts, but the provided callback system (as advised in a previous
> > post).
>
> > I suggest you buy yourself a good book on Prototype[1] and maybe one
> > on JavaScript too, while you're at it. ;)
>
> > Best,
>
> > Tobie
>
> > [1]http://prototypejs.org/2008/8/11/practical-prototype-and-scriptaculous
> > orhttp://prototypejs.org/2007/5/7/prototype-and-script-aculo-us-the-bun...
>
> > On Mar 3, 1:43 am, BearState <wixelb...@yahoo.com> wrote:
>
> > > Hidie-ho,
>
> > > Well Ok, I've used setTimeout a few times in my code to delay resuming
> > > run of a code module until Ajax.Request() has had time to do its
> > > thing.   And the use of the timer is cyclic as the user may repeat the
> > > operation over and over again, but in different parts of the page.
>
> > > And ...  holy spacetime wormhole continuum out of wack batman!  Why is
> > > that timer firing off so quickly?   What in the wide wide world of
> > > sports is go'n on?
>
> > > Robin, haven't you done a web search yet?   There's people complaining
> > > about memory leaks with regard to timers?
>
> > > Holy abscent minded browser batman!   Is it the setTimeout() function
> > > causing the problem?
>
> > > Damned if I know Robin, I only stomp on Penquins and Jokers, not
> > > memory leaks and I'm not int he habit of waiting for anything, not
> > > even queues at the bank when I cash my checks.
>
> > > Holy Fast Food Diet out the window with Cheese, Fries and Shake
> > > Batman!  What's the answer?
>
> > > You weren't listening Robin ...  damned if I know.
>
> > > Does anyone know?
>
> > > BearState- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to