On Tue, Sep 15, 2009 at 12:21 AM, kangax <[email protected]> wrote:
>
> You must be joking :)
not really :)
> How is this to "avoid any kind of problem" when
> you base your code on unspecified, non-standard and generally known to
> be quirky behavior?
the same way we all use innerHTML :P
> here's a quote from ES5:
>
> <quote>
> NOTE
> Several widely used implementations of ECMAScript are known to support
> the use of FunctionDeclaration as a Statement. However there are
> significant and irreconcilable variations among the implementations in
> the semantics applied to such FunctionDeclarations. Because of these
> irreconcilable difference, the use of a FunctionDeclaration as a
> Statement results in code that is not reliably portable among
> implementations. It is recommended that ECMAScript implementations
> either disallow this usage of FunctionDeclaration or issue a warning
> when such a usage is encountered. Future editions of ECMAScript may
> define alternative portable means for declaring functions in a
> Statement context.
> </quote>
>
it's nice how you think this way is different from the other. Do you truly
think for IE there is any difference writing function a(){} or simply
function ?
The nature of IE is to keep everything, var f = ((((function(){})))) will
bring every bracket with it, if you redefine f later IE will still have in
memory a ((((function(){})))) declaration.
I agree that being not standard my suggestion is quite tricky, but at the
same time, being not standard, behavior speaking, you can hardly prove your
way does not create the same situation.
The difference is that you are referencing the declaration in to a variable,
and you said that in IE:
function a(){};
var $a = a;
$a is basically NOT the function a, and function a will persist in that
scope. In few words, the fact we cannot reach an unassigned anonymous
function, does not mean it does not exist, got my point?
Btw, your post is right, and probably future or ES5 proof, my point is that
ES5 does not mean cross-browser behavior, we already have a lot of
discrepancy between most recent browsers.
Accordingly, I will change my mind the day this behavior will be truly
standard, before it is all about assumptions, and I like to keep code size
as small as possible, if it is my code, of course :-)
@Michael Geary, it seems you never have to debug your code, do you? It is a
good practice to name functions 'cause thousands of "anonymous" error are
quite meaningless. My example is a de-facto behavior, with named functions.
>
> It's up to end developer to choose which way to go, of course.
>
Definitively
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---