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

Add ways of accessing locals from higher scopes? #77

Open
dloscutoff opened this issue Mar 26, 2024 · 0 comments
Open

Add ways of accessing locals from higher scopes? #77

dloscutoff opened this issue Mar 26, 2024 · 0 comments
Labels
brainstorming Less of an issue, more of a place to kick around ideas. compatibility-breaking Making this change would break backward compatibility.

Comments

@dloscutoff
Copy link
Owner

My original plan, a while back, was for \a et al to refer to the value of the local variable at the next higher scope level. I implemented it as global variables referring to the program args instead, mainly because it was easier and that's usually what's wanted. However, there are some cases where the local variable reference would be useful and distinct from the program arg reference. Maybe we can have both?

  • \a refers to the value of a at one scope level up
  • $a refers to the first program argument
  • \\a refers to the value of a at two scope levels up (and so on for more backslashes; would require a change to the scanner)

The main problems here:

  • This change potentially breaks backward compatibility, although I'm not sure if any of the programs that use \a so far would actually break.
  • $a doesn't scan the same as \a; in particular, you can't have another lowercase variable, number, or underscore after it without a space in between. This problem is somewhat mitigated by the fact that in many situations, \a will refer to the same value as $a and can be used instead.

Investigate how much of a problem these problems actually are.

@dloscutoff dloscutoff added compatibility-breaking Making this change would break backward compatibility. brainstorming Less of an issue, more of a place to kick around ideas. labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brainstorming Less of an issue, more of a place to kick around ideas. compatibility-breaking Making this change would break backward compatibility.
Projects
None yet
Development

No branches or pull requests

1 participant