Function inside if statement?

Mike Wilson mikewse at hotmail.com
Wed Feb 6 00:55:37 PST 2008


Sorry if this was already covered by your summary, but I can confirm
that
  if (true) function f() {}
yields a SyntaxError in Safari 2.0.4, while
  if (true) { function f() {} }
works fine.

Best regards
Mike

> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org 
> [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of liorean
> Sent: den 6 februari 2008 01:42
> To: es4-discuss at mozilla.org
> Subject: Re: Function inside if statement?
> 
> Just wanted to point out the thread starting here:
> <uri:https://mail.mozilla.org/pipermail/es4-discuss/2007-March
> /000483.html>.
> 
> It discusses this issue. Brendan gave this answer, a few replies in:
> > Since this is an ES3 extension, allowed by chapter 16, we could
> > codify the majority-share practice, except that it sucks. We have so
> > far avoided specifying function statements, preferring to leave them
> > to implementations to experiment with, on into the ES4 future.
> 
> 
> 
> I did a summary of what the engines did in various browsers at:
> <uri:https://mail.mozilla.org/pipermail/es4-discuss/2007-March
> /000495.html>
> The discussion detours a bit after that.
> 
> Also, Microsoft included these tests as section 2.9 in their "JScript
> Deviations from ES3" document at:
> <uri:http://wiki.ecmascript.org/lib/exe/fetch.php?id=resources
> %3Aresources&cache=cache&media=resources:jscriptdeviationsfromes3.pdf>
> 
> Note that the reason Safari according to that document doesn't give
> any results is that the test uses plain function declarations in the
> statement bodies. If the statement bodies had been wrapped in a
> statement list (curlies) then Safari would have given a profile very
> similar to that of Firefox except for the
> break-within-labelled-statement case, IIRC.
> In other words, to do a full set of tests one need to try both the
> statement-list wrapped versions and the plain function declaration
> versions, because they may have differing results.
> -- 
> David "liorean" Andersson
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
> 




More information about the Es4-discuss mailing list