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

Cannot "set" a variable that later will become a "lock". #13

Closed
Dunbaratu opened this issue Mar 22, 2014 · 1 comment
Closed

Cannot "set" a variable that later will become a "lock". #13

Dunbaratu opened this issue Mar 22, 2014 · 1 comment
Assignees
Labels
bug Weird outcome is probably not what the mod programmer expected.

Comments

@Dunbaratu
Copy link
Member

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'.)

@marianoapp marianoapp added the bug label Mar 22, 2014
@marianoapp marianoapp self-assigned this Mar 22, 2014
@marianoapp
Copy link
Contributor

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.

erendrake pushed a commit that referenced this issue Apr 14, 2015
Pulling latest changes into my branch.
erendrake pushed a commit to erendrake/KOS that referenced this issue May 19, 2015
Pulling changes from the main repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Weird outcome is probably not what the mod programmer expected.
Projects
None yet
Development

No branches or pull requests

2 participants