You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
print "starting.".
set var to "set value".
print "set var is: " + var.
lock var to "locked value".
print "locked var is: " + var.
Result:
starting.
Variable var* is not defined
Instruction 10
When going through and parsing the script ahead of time, kOS sets up conditions such that if var will at any point in the script be used in a lock command it cannot ever be used in a set command elsewhere in the script (even at an earlier point in the script).
(suggestion for fix: if it's going to be a lock such that it must be a function returning a value, then when the 'set' is encountered make kOS translate that kosscript code into this k-risc code:
step 1 - evaluate expression into a temp value.
step 2 - lock variable to that constant temp value.
This way the variable always is a 'lock' even when used as a 'set'. The 'lock' is locking to a value that was calculated just once instead of each time - so it behaves like a 'set'.)
The text was updated successfully, but these errors were encountered:
Actually it already does something like this, before you "lock" a variable the function pointer points to a function that returns a variable with the same name as the lock identifier.
What is missing is the possibility to "set" this default variable but that shouldn't be too hard to implement.
Result:
When going through and parsing the script ahead of time, kOS sets up conditions such that if var will at any point in the script be used in a lock command it cannot ever be used in a set command elsewhere in the script (even at an earlier point in the script).
(suggestion for fix: if it's going to be a lock such that it must be a function returning a value, then when the 'set' is encountered make kOS translate that kosscript code into this k-risc code:
step 1 - evaluate expression into a temp value.
step 2 - lock variable to that constant temp value.
This way the variable always is a 'lock' even when used as a 'set'. The 'lock' is locking to a value that was calculated just once instead of each time - so it behaves like a 'set'.)
The text was updated successfully, but these errors were encountered: