Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

while(true){...} error #7

Open
GoogleCodeExporter opened this issue Mar 24, 2015 · 4 comments
Open

while(true){...} error #7

GoogleCodeExporter opened this issue Mar 24, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

while(true){...} error

Original issue reported on code.google.com by zhoujr.m...@gmail.com on 29 Dec 2011 at 9:10

@GoogleCodeExporter
Copy link
Author

Hi, 

Do you have any example code?

I'm not sure we support break in while loops (maybe on Armin's branch) so while 
(true) will always just be an infinite loop...

Original comment by pur3m...@googlemail.com on 29 Dec 2011 at 3:40

@GoogleCodeExporter
Copy link
Author

Hi, 
Please see the statement: "int loopCount = TINYJS_LOOP_MAX_ITERATIONS;"
{
    var i = 0;
    while (true)i++;
}
After run the above statements, TinyJS will throw an exception 
"CScriptException("LOOP_ERROR")".
[WHILE Loop exceeded 8912 iterations]
I don't know what's the reason of limiting LOOP COUNT, and can you tell me?

The break in while loops is supported on Armin's branch, but not on the trunck.
The prefix opertation "++" and "--" is not supported too.

I tried to use code on Armin's branch, but it don't support some important key 
words too. Such as "var sObject = new Object();".

I hope you can support the break operation.
Waiting for you, thank you!

Original comment by zhoujr.m...@gmail.com on 29 Dec 2011 at 4:40

@GoogleCodeExporter
Copy link
Author

The reasoning is that TinyJS is designed for scripting applications - as such 
it's generally used for very small loops. If you have lots of loop iterations 
we assume it's generally a bug in the script - and not getting stuck in an 
infinite (or huge) loop is a useful feature that has come in handy for me.

If you want more leeway, just set TINYJS_LOOP_MAX_ITERATIONS to something big. 
TinyJS isn't that fast, so setting it to 2 billion is effectively infinite.

As for the lack of Prefix, this is documented at the top of TinyJS.cpp, along 
with some other things that aren't implemented/don't work.

Break/continue may be implemented at some point, but not soon, and probably not 
by me. I use TinyJS for scripting in my applications, and for that, the current 
subset of Javascript is more than sufficient.

Armin's branch *does* support 'new' though, so maybe the only problem you have 
is with the use of 'Object'?

I'm afraid that if you're after a fully-featured JavaScript interpreter, you're 
probably better off going elsewhere. TinyJS is designed to be simple, and as 
such supporting the whole of the ECMAScript standard really isn't what it's 
about.

Original comment by pur3m...@googlemail.com on 5 Jan 2012 at 5:31

@GoogleCodeExporter
Copy link
Author

Thanks, I got it.

Original comment by zhoujr.m...@gmail.com on 6 Jan 2012 at 1:49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant