If you had posted the link to the question in the JS room instead of invitespamming people (I do see how many invites you have sent...) I'd have helped you.
In case anyone else here thinks inviting people to a separate room makes them more likely to help.
@FLCL Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
oh, someone will also need to host the bot. @rlemon said he may be able to, I've got vibes from @OctavianDamiean (but it may just be him checking out my muscular abs).
@Zirak you're wrong my friend. 1st we were talking about dynamic scopes and not variables and there, ECMAscript does not use any kind of dynamic scoping. Its strictly lexically still.
But go ahead, do by all means show me how better than Eric Lippert of Brandan Eich you got scoping in JS. Find a way to say it with your pute english. Educate them.
@BenjaminGruenbaum however and after all, your argument is invalid. Even IF I'd agree that with with you can change the scope dynamically, its not implemented in the language itself which I was saying all the time
@jAndy look it up in es-discuss. I don't want to appeal to authority though I just got a bit upset you linked me to that article since I've discussed it here several times.
function foo() {
var x = 10;
return function bar() {
console.log(x);
};
}
// "foo" returns also a function
// and this returned function uses
// free variable "x"
var returnedFunction = foo();
// global variable "x"
var x = 20;
// execution of the returned function
returnedFunction(); // 10, but not 20
if the result there was 20
then we would have dynamic scoping in the language
We have dynamic scoping in with statements, not in functions. It's not a dynamically scoped language. It's a lexically scoped language with dynamic scoping with the with construct.
When you search the pros and cons you get this nice list of the same items, just worded differently. Pros: easy, fast Cons: security, rendering
But my angle is more, considering javascript is an interpreted language, uses prototyping and is dynamically typed?
> The with statement adds an object environment record for a computed object to the lexical environment of the current execution context. It then executes a statement using this augmented lexical environment. Finally, it restores the original lexical environment.
That's like saying JS is not a functional language because it has non functional constructs. Or that it's not an OOP language because it does have functional constructs...
and I don't know how I can express myself any better. ECMAscript is about context and scoping chains (or call it LEXICAL environment records and stuff). Just because there is one ill keyword in the language which can swap order of execution context, can't be a reason to call the language has "dynamic scope"
its more like, I have a perfect green tower and just because there is one crazy guy in there who carrys a bucket with red color and he COULD potentially paint some reds... now the tower isn't green
@OctavianDamiean probably, but all I originally said was that ECMAscript (the language itself and its conception) does not use any kind of dynamic scoping and all the sudden @BenjaminGruenbaum jumped it and all this started
talking about the green building, not any potential red buckets