elnewfie / lslforge

Automatically exported from code.google.com/p/lslforge
24 stars 13 forks source link

State change in function #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a function that uses the 'conditional' hack to change states, like 
this:

bugstate() {
    if (TRUE)
        state otherState;
}

What is the expected output? What do you see instead?
Expected output: a warning about changing states in global functions.
Observed: The error "state changes not allowed from this context" - LSLForge 
Problem
This prevents the .lsl script from being assembled.

What version of the product are you using? On what operating system?
Linux Mint

Please provide any additional information below.

Original issue reported on code.google.com by rene.te...@gmail.com on 11 Mar 2013 at 3:57

GoogleCodeExporter commented 9 years ago
  LSL wiki says:
User-defined (global) functions cannot change a script's state. The compiler 
will throw the error 'ERROR: Global functions can't change state'. Note: 
Previously, global functions could change state in the body of a simple 'if' 
statement; this "workaround" no longer works.
  (from http://wiki.secondlife.com/wiki/State)
  So it's not a issue.

Original comment by pells...@gmail.com on 17 Apr 2014 at 6:45

GoogleCodeExporter commented 9 years ago
That wiki remark was added on 6 june 2010. I appears to me that in practice the 
LL wiki is not correct on this.

At the moment, april 2014, this 'hack' still works. Disabling it would break a 
lot of existing code, so it's unlikely LL will change this in the near future 
without explicit reason.

Original comment by rene.te...@gmail.com on 17 Apr 2014 at 11:19

GoogleCodeExporter commented 9 years ago
  I remember it didn't work in beta grid before, but it seemed my misunderstanding.  It worked today in main grid.  And I found for, while and do while statement allow this hack.  Are there any other cases?
  It's very strange to inhibit state changing in function, it's not a technical problem, but this is not a place discussing it.
  There are 3 points to fix it.

1. How LSLForge should work
2. How to change LSLForge compiler
3. How to change LSLForge debugger

For 1., we need to research all cases to allow state change in global 
functions. (It's a troublesome task to implement such a buggy spec.)
For 2., I made some patches for LSLForge compiler but I don't understand to 
show warnings yet.
And 3., I haven't read around LSLForge debugger yet, need some time to learn it.

I'm not sure when I can finish it, but not impossible.
Wait for a while...

Original comment by pells...@gmail.com on 18 Apr 2014 at 6:45