From: Scott Sauyet on
On Feb 3, 3:27 pm, "Dmitry A. Soshnikov" <dmitry.soshni...(a)gmail.com>
wrote:
> Addition: it is fair for any implementation which allows access to the
> activation object (and its properties) of a function.

Thanks for all the pointers. Very interesting stuff, there.

-- Scott
From: RobG on
On Feb 4, 1:41 am, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
[...]
>  There is
> something to be said for Garrett's function re-writing, though, too,
> which I might write a little more explicitly like this:
>
>     var openWin = function(aURL) {
>       var myWin;
>       openWin = function(aURL) {
>         if (!myWin || myWin.closed ) {
>           myWin = window.open(aURL,'myWin');
>         } else {
>           myWin.location.href = aURL;
>           myWin.focus();
>         }
>         return myWin;
>       };
>       return openWin(aURL);
>     };
>
> One advantage to this is that before this function is called, there is
> no function call performed to define it and no variable declaration
> made. Certainly this is not an issue with such minor initialization,
> but for a function that possibly would never be called and that
> requires substantial initialization, I can easily see an advantage to
> this. On the other hand, if this initialization is time-consuming,
> perhaps waiting for a user-initiated event to run it would be
> problematic too.

Peter Michaux has a blog entry on what he calls "lazy function
definition" that seems relevant:

<URL: http://peter.michaux.ca/articles/lazy-function-definition-pattern
>


--
Rob
From: Scott Sauyet on
On Feb 3, 6:01 pm, RobG <rg...(a)iinet.net.au> wrote:
> On Feb 4, 1:41 am, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
>
> Peter Michaux has a blog entry on what he calls "lazy function
> definition" that seems relevant:
>
> <URL:http://peter.michaux.ca/articles/lazy-function-definition-pattern

Yes, that's a very good discussion on the subject. I'd seen the
article and the technique before, but hadn't really considered it in
terms of this sort of problem until Garrett brought it up.

Thanks,

-- Scott