Global functions
On 14/12/2007, Michael O'Brien <mob at mbedthis.com> wrote:
So should functions be treated like var declarations or as let declarations. Seems like they are like vars in the RI.
Is this right?
I don't see how they could be anything else for ES3 compatibility's sake. At least, within a single compilation unit.
I was under the impression that for the function definitions to be confined to a block scope, you had to define them as such (with let function statements), like so:
package { { let function fun() { print("1"); } fun() } { let function fun() { print("2") } fun() } }
I'm unsure if this currently works in the RI, or not.
While this compiles in the RI, it still produces 2 and 2 for the output.
ie. doesn't seem they are block scoped functions either.
Michael
I believe "let function" is broken in the RI (it has been in the past).
On Dec 13, 2007, at 11:42 PM, Lars T Hansen wrote:
I believe "let function" is broken in the RI (it has been in the
past).
I encouraged Michael to file a trac ticket, and he did:
bugs.ecmascript.org/ticket/337
Anyone else who finds an RI bug and can't see a report of it in the
existing tickets, feel free to run it by this list and file if it's
not known -- or just file and we'll dup it in due course. These
tickets will be fixed. Anyone who wants to help hack on the RI,
please contact me. Thanks,
Also see bugs.ecmascript.org/ticket/158.
Are global functions declared with block or global scope. ie. declared in the block object or var object?
Consider:
package { { function fun() { print("1"); } fun() } { function fun() { print("2") } fun() } }
This prints
2 2
in the RI.
So should functions be treated like var declarations or as let declarations. Seems like they are like vars in the RI.
Is this right?
Michael O'Brien
Are global functions declared with block or global scope. ie. declared in the block object or var object? Consider: package { { function fun() { print("1"); } fun() } { function fun() { print("2") } fun() } } This prints 2 2 in the RI. So should functions be treated like var declarations or as let declarations. Seems like they are like vars in the RI. Is this right? Michael O'Brien