Re: What do people use Venkman for?
"7stud" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jsdebugger |
|---|---|
| Message-ID | <[email protected]> |
Hi, Thanks for the responses. After doing a bunch of tests, and getting confirmation from someone else on a js forum, I came to the same conclusion. However, the amount of work and frustration that went into that whole process seems entirely unnecessary. First, the tutorial, which is mentioned on several Venkman pages as being excellent: http://www.svendtofte.com/code/learning_venkman/basics.php is flat out wrong when it describes what will happen when you step through code. How can the open source community hold that tutorial up as a representation of how Venkman works? Secondly, doesn't having to step through all the variable declarations essentially make Venkman useless for large scripts? Someone might have to step through 50 variable declarations interspersed in 1,000 lines of code just to get to the start of the script? I also have a question about setting watches. The first time I tried it, it was simple. As I remember it, I clicked on the Watches tab, right clicked on the Watches window, and dialog box popped up, where I entered in the variable name. Now, when I try to add a Watch, I get this error: Internal error dispatching command 'watch-expr". Reference Error: treeView is not defined @< chrome://venkman/content/venkman-views.js>123 Can anyone tell me what I am doing wrong? Thanks. "Martin Honnen" <[email protected]> wrote in message news:[email protected]... > > > Robert North wrote: > > > > I think the debugger is working, but it does a first pass over the code, > > creating global variables, and setting them to null. > > Then, it goes back and runs the code *properly*. > > Well check the ECMAScript specification, it is *proper* execution to > first processs variable declarations to create variables. You can find > details about that in the section "12.2 Variable statement" of the > ECMAScript edition 3 specification where it says > "Variables are created when the execution scope is entered. A Block > does not define a new execution > scope. Only Program and FunctionDeclaration produce a new scope. > Variables are initialised to undefined > when created. A variable with an Initialiser is assigned the value of > its AssignmentExpression when the > VariableStatement is executed, not when the variable is created." > > So what you see in Venkman is simply the script engine creating the > variables first and initializing them to undefined, there is nothing > wrong with that. > > This is different from languages like Java where variables have block > scope. In JavaScript/ECMAScript you can even access a variable before > its declaration e.g. > > if (x == 3) { > print(x); > } > var x; > > as the execution of that program first looks for variable declarations > and creates variables. You could say that in ECMAScript variable > declarations are "hoisted" to the beginning of the execution scope. > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/