|
Gargling Ginsberg
Registered User
Join date: 7 Oct 2006
Posts: 29
|
10-27-2006 17:43
Throw this in a script and give it a try. The comments explain the error. { integer i; integer MAX=3; //incorrectly runs the i=2 state for(i=0;i<3-1;i++) llOwnerSay((string)i); //Still incorrectly runs the i=2 state // so this isn't an operator precedence issue for(i=0;i<  3-1);i++) llOwnerSay((string)i); //won't even COMPILE this (complains of syntax error) // It doesn't like the minus sign //for(i=0;i<MAX-1;i++) // llOwnerSay((string)i); //Again, won't even compile //for(i=0;i<  MAX-1);i++) // llOwnerSay((string)i); //Yet this works for(i=0;i<3+1;i++) llOwnerSay((string)i); //And this works for(i=0;i<MAX+1;i++) llOwnerSay((string)i); }
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
10-27-2006 17:55
I think this is it thinking "-1" means "negative one", the integer rather than "minus one", meaning an operator then an integer. Try putting a space between the - and the 1.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Gargling Ginsberg
Registered User
Join date: 7 Oct 2006
Posts: 29
|
10-27-2006 18:04
That's one annoying compiler bug. Thanks for the suggestion to side step it for now (I tried it and that is a successful work around).
I'm not sure that explanation is entirely correct though, as the first block doesn't make sense then (why does it compile at all?).
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
10-28-2006 04:38
From: Gargling Ginsberg (why does it compile at all?). No idea sorry.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
10-28-2006 11:30
Maybe its idea of valid numbers is lax, like a regex of /[-0-9.]*/, so it sees "3-1" as an integer constant, and then runs it through the C function atoi(), resulting in "3"?
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
10-28-2006 15:42
The LSL parser is really horrid, it's full of stuff like this. They need to implement constant folding so they don't have to special-case negative numbers.
|