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

LOCAL for already-existing variable clobbers variable #154

Open
jasonsikes opened this issue Feb 3, 2023 · 2 comments
Open

LOCAL for already-existing variable clobbers variable #154

jasonsikes opened this issue Feb 3, 2023 · 2 comments

Comments

@jasonsikes
Copy link

Is this a bug?

? to g
> localmake "foo "bar
> local "foo
> show :foo
> end
g defined
? g
foo has no value  in g
[show :foo]

I can see how this happens. LOCAL creates a placeholder in the variable stack and assigns the value {nothing}. But if a value already exists should it be clobbered?

@jrincayc
Copy link
Owner

jrincayc commented Feb 3, 2023

Hm, I am not sure. @brianharvey what are your thoughts?

@brianharvey
Copy link
Collaborator

Good question.

"If a variable already exists" is the wrong condition, though, since variables are inherited from any outer scope. So, if you were to change this, it'd have to be "if a variable of the same name has already been created in this procedure call..."

The current behavior has been the case right from the beginning of ucblogo, so if it's a bug it's a longstanding one. The manual is silent on the question. So I think it's okay to keep the current behavior, but I agree that the suggested change would be an improvement, just in case the LOCAL is inside a FOR loop or some such thing.

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