The problems areas you want to look at are:
The problems areas you want to look at are:
And I suggest adding FunctionExpression name scope to this list.
On Thu, Feb 28, 2013 at 2:18 AM, John Lenz <conca...@gmail.com> wrote:
The problems areas you want to look at are:
catch expressions (which introduce a scope)
with blocks (which introduces an object as a scope)
global scope (which is complex blending of browser properties, window
object properties, and global variables)
On Wed, Feb 27, 2013 at 6:20 PM, Yusuke SUZUKI <utata...@gmail.com> wrote:All of the above.
>> The problems areas you want to look at are:
Additionally, when doing this at runtime, keep in mind that you have
no way of telling whether a scope is garbage collected. So every time
you create a new function, and a new scope object, it will never
disappear (unless you do the hard work for it as well, of course).
Statically, it's fine of course, since you only have to create one
scope object per scope (globla/function/catch). I'm not sure how you
could do with safely (statically), though.
Yusuke's project can be useful as well: https://github.com/Constellation/escope.
--
--
http://clausreinke.github.com/js-tools/resources.html - tool information
http://groups.google.com/group/js-tools - mailing list information
---
You received this message because you are subscribed to the Google Groups "js-tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to js-tools+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Yusuke's project can be useful as well: https://github.com/Constellation/escope.
escope is used to implement esmangle minifier / optimizier[1], it handles ECMA262 scope precisely (example[2]).And it is also used by keeyipchan's estoggles[3], JavaScript scope information viewer (demo[4])
Bear.prototype.attack = function attack() { function rage() { } return 'claw' }
jjb
it seems like we have three scopes:
1 Global, -- contains Bear
2) attack, -- contains attack, rage
3) rage -- empty
The production
FunctionExpression : function Identifier ( FormalParameterListopt ) { FunctionBody }
is evaluated as follows:
1. Let funcEnv be the result of calling NewDeclarativeEnvironment passing the running execution context’sLexical Environment as the argument
2. Let envRec be funcEnv’s environment record.
3. Call the CreateImmutableBinding concrete method of envRec passing the String value of Identifier as the argument.
4. Let closure be the result of creating a new Function object as specified in 13.2 with parameters specified by FormalParameterListopt and body specified by FunctionBody. Pass in funcEnv as the Scope. Pass intrue as the Strict flag if the FunctionExpression is contained in strict code or if its FunctionBody is strict code.
5. Call the InitializeImmutableBinding concrete method of envRec passing the String value of Identifier andclosure as the arguments.
6. Return closure.
How can we detect the immutability of the binding in 13.3?
(function () {
'use strict';var i = function attack() {
attack = 'test';};i(); // Error should be raised}());
is this really just a theoretical explanation or do we really need to create this extra scope?
--
--
http://clausreinke.github.com/js-tools/resources.html - tool information
http://groups.google.com/group/js-tools - mailing list information
---
You received this message because you are subscribed to the Google Groups "js-tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to js-tools+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
How can we detect the immutability of the binding in 13.3?We can detect this immutability by using following code[1],(function () {'use strict';var i = function attack() {attack = 'test';};i(); // Error should be raised}());Caution: SpiderMonkey, JSC and my engine[2] handles it correctly, but V8 doesn't. It's V8 bug.
is this really just a theoretical explanation or do we really need to create this extra scope?Practically we can remove extra scope creation in scope analyzer tools - instantiating inner scope, and at the end instantiate immutable function name binding to inner scope only when inner scope doesn't have binding which name is the same to function name.But one of escope project purposes is constructing scope analyzer that is extremely precise to ECMA262 5.1th spec, so we handle these edge cases completely.
--