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

Inconsistent behavior under NetLogoWeb #18

Closed
arcpaolo opened this issue Jun 21, 2023 · 4 comments
Closed

Inconsistent behavior under NetLogoWeb #18

arcpaolo opened this issue Jun 21, 2023 · 4 comments

Comments

@arcpaolo
Copy link

arcpaolo commented Jun 21, 2023

When running this code:

extensions [ table ]
globals [ $#table $t1 ]
to go
  set $#table table:make
  set $t1 table:get $#table "Test"
end

In the desktop version (6.3.0) you get an error: "Extension exception: No value for Test in table."

However, when running in NetLogoWeb, you don't get an error, $t1 is set to "undefined".

I have some code that checks to see if a certain table key already exists to avoid overwriting. I used "carefully [ ]" and then ignored the error if there was no such key. When I run on NLW this check no longer works.

As a stop-gap, is there a way to test if a variable is "undefined"? I could not figure out how to do this. It's not a boolean nor does it seem to be a primitive of any sort.

@CIVITAS-John
Copy link

CIVITAS-John commented Jun 21, 2023 via email

@arcpaolo
Copy link
Author

Ah, of course. I should have thought of that, I just tried it and it works. Nonetheless it would be useful if the behavior were consistent.

I am also curious how one can check if a variable is undefined in NLW.

@LaCuneta
Copy link
Contributor

Thanks for reporting this. I have a fix here and will merge it and close this issue once tests pass. There was a check for a missing key for a key with a list value, but no check for simple valued keys. There was a test for this here in the desktop repo, but somehow that test got dropped when the extension was ported to NetLogo Web. At some point we should get those tests back in sync, but for now I just added a new one to Tortoise.

I am also curious how one can check if a variable is undefined in NLW.

So, in theory this should never be necessary. NetLogo doesn't allow an undefined value, so NetLogo Web doesn't, either. The only time this would happen is with bugs (as in this case) or due to the lack of full runtime error checking. All NetLogo variables are initialized to 0 and the closest you see to undefined is the Nobody value for an agent that some reporters can produce.

@arcpaolo
Copy link
Author

Thank you!

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

No branches or pull requests

3 participants