![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Because people likes things to have a name, the obvious name to apply to it is "javascript". And that is what everybody else have been doing, consistently, for as long as it has mattered (q.v. the name of this group). I.e., it's *common usage*. Not formal definition, not official standard, but still quite valid. |
#12
| |||
| |||
|
|
VK wrote: Firefox 2.0.0.14 - 1000 iterations limit As I said, such an analysis is superficial at best: for (var i = 1; i < n; i++) ; causes a warning when n == 1000000 because of my Firefox's "dom.max_script_run_time" preference set to 1800 (for testing purposes). |
#13
| |||
| |||
|
|
Lasse Reichstein Nielsen wrote: Because people likes things to have a name, the obvious name to apply to it is "javascript". And that is what everybody else have been doing, consistently, for as long as it has mattered (q.v. the name of this group). I.e., it's *common usage*. Not formal definition, not official standard, but still quite valid. When "common usage" proves insufficient to explain certain phenomena, it should be replaced by more precise terms, especially in a discussion in a technical environment. |
#14
| ||||
| ||||
|
|
On May 17, 8:49 pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de wrote: Lasse Reichstein Nielsen wrote: Because people likes things to have a name, the obvious name to apply to it is "javascript". And that is what everybody else have been doing, consistently, for as long as it has mattered (q.v. the name of this group). I.e., it's *common usage*. Not formal definition, not official standard, but still quite valid. When "common usage" proves insufficient to explain certain phenomena, it should be replaced by more precise terms, especially in a discussion in a technical environment. Like what? - I am writing JavaScript1.5 program for Firefox, I am writing JavaScript1.7 program for Firefox, I am writing JScript program for IE6, I am writing JScript program for IE7, I am learning ECMAScript and shall be blessed all other names which are not here. Amen! ... this line gives me an error: document.write("John "Bool" Smith"); Why? - Your JavaScript1.5 program for Firefox, your JavaScript1.7 program for Firefox, your JScript program for IE6, your JScript program for IE7, your ECMAScript and shall be blessed all other names which are not here. Amen! ... doesn't work because it has nested quotes of the same type. Either replace outer quotes by single ones, or escape inner ones: document.write('John "Bool" Smith'); document.write("John \"Bool\" Smith"); Are you really insisting on such dialogs at c.l.j.? :-) |
|
There is JavaScript in many variants, |
|
there is JScript in many variants, |
|
there is also ActionScript |
#15
| ||||||
| ||||||
|
|
Firefox 2.0.0.14 - 1000 iterations limit And if you meant recursions instead of iterations, Well, we are changing the amount of iterations to check the allowed limit of recursions :-) |
|
but you are right with the correction. (function f(x) { console.log(x); f(x + 1); })(0); stops with a stack overflow after logging 994. Tested in Firebug 1.1.0b12, Firefox 2.0.0.14. You are missing 6 recursions because 1) 2 are used even before going to the loop: |
|
for anonymous function wrapper ()() and for f() inside it. |
|
2) The rest is used for anonymous wrappers for your code in Firebug. [...] |
|
Drop Firebug and use this instead: Again, 999 because one stack position is already used for the entry point. |
|
Change to 1000 to break the script. |
#16
| |||||
| |||||
|
|
VK wrote: Firefox 2.0.0.14 - 1000 iterations limit And if you meant recursions instead of iterations, Well, we are changing the amount of iterations to check the allowed limit of recursions :-) You are not making sense. but you are right with the correction. (function f(x) { console.log(x); f(x + 1); })(0); stops with a stack overflow after logging 994. Tested in Firebug 1.1.0b12, Firefox 2.0.0.14. You are missing 6 recursions because 1) 2 are used even before going to the loop: There is no loop. |
|
for anonymous function wrapper ()() and for f() inside it. No, it is the same number if I use function f(x) { console.log(x); f(x + 1); } f(0); |
|
2) The rest is used for anonymous wrappers for your code in Firebug. [...] It is the same number when using javascript: function f(x) { console.log(x); f(x + 1); } f(0); in the Location Bar. With javascript: document.open(); function f(x) { document.write(x + "<br>"); f(x + 1); } f(0); document.close(); it is 999, not 1000. |
|
Drop Firebug and use this instead: Again, 999 because one stack position is already used for the entry point. A recursion does not occur until the method calls itself. So it is 999 recursions, if that. |
|
Change to 1000 to break the script. I am not changing anything; your test is flawed (and includes a lot of unnecessary code again). It should count forwards, not backwards. |
#17
| ||||||||
| ||||||||
|
|
On May 17, 11:44 pm, Thomas 'PointedEars' Lahn <PointedE... (AT) web (DOT) de wrote: VK wrote: Firefox 2.0.0.14 - 1000 iterations limit And if you meant recursions instead of iterations, Well, we are changing the amount of iterations to check the allowed limit of recursions :-) You are not making sense. |
|
but you are right with the correction. (function f(x) { console.log(x); f(x + 1); })(0); stops with a stack overflow after logging 994. Tested in Firebug 1.1.0b12, Firefox 2.0.0.14. You are missing 6 recursions because 1) 2 are used even before going to the loop: There is no loop. Look closer. |
|
for anonymous function wrapper ()() and for f() inside it. No, it is the same number if I use function f(x) { console.log(x); f(x + 1); } f(0); because there are still two stack position used: for f(0) call and for f(x) for the initial enter. |
|
The only difference from the first option is that here the first stack position is taken by a named function and in the first example - by an anonymous function. Sorry, but you really should refresh the stack mechanics theory during this week-end. |
|
2) The rest is used for anonymous wrappers for your code in Firebug. [...] It is the same number when using javascript: function f(x) { console.log(x); f(x + 1); } f(0); in the Location Bar. With javascript: document.open(); function f(x) { document.write(x + "<br>"); f(x + 1); } f(0); document.close(); it is 999, not 1000. Same explanation, same suggestion to you. |
|
You simply cannot start executing a function without executing it at least once. This is why for top level tests you have to add 1 to the result. |
|
option is to watch the stack size itself on the system level. |
|
Drop Firebug and use this instead: Again, 999 because one stack position is already used for the entry point. A recursion does not occur until the method calls itself. So it is 999 recursions, if that. Recursion starts then you call a function, because it still requires a return point to store. Even such everyday trivia like myFunction(args); is in fact a "micro recursion" one level deep with the return point set to the code immediately following the function call. |
#18
| |||||
| |||||
|
|
You are missing 6 recursions because 1) 2 are used even before going to the loop: There is no loop. Look closer. There still is no loop. |
|
A loop would mean iteration, this is recursion. |
|
You have argued that the anonymous function wrapper would introduce one recursion; I have disproved that. |
|
The only difference from the first option is that here the first stack position is taken by a named function and in the first example - by an anonymous function. Sorry, but you really should refresh the stack mechanics theory during this week-end. Pot, cattle, black. |
|
You simply cannot start executing a function without executing it at least once. This is why for top level tests you have to add 1 to the result. No, I don't. There are 999 recursions possible, if that, not 1000. |
#19
| |||||
| |||||
|
|
You are missing 6 recursions because 1) 2 are used even before going to the loop: There is no loop. Look closer. There still is no loop. Yet even more closer than :-) |
|
A loop would mean iteration, this is recursion. Ah, OK, I see your problem now. The function f calls itself over and over again until all allowed resources are used - it is an endless loop. The "loop" term is not exclusively attached neither to iterations nor to recursions. |
|
| -->o |--- |
| v |
| v |
#20
| ||||
| ||||
|
|
You are mistaken. When a function calls itself, i.e. recursion occurs, that is _not_ considered a loop. |
|
A loop is something that closes back on itself. |
|
sum (x::xs) acc = sum xs (acc+x) |
|
In ECMAScript terms: While the called object remains the same, the execution context does not. |
![]() |
| Thread Tools | |
| Display Modes | |
| |