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

document const semantics #888

Closed
andychu opened this issue Jan 11, 2021 · 6 comments
Closed

document const semantics #888

andychu opened this issue Jan 11, 2021 · 6 comments

Comments

@andychu
Copy link
Contributor

andychu commented Jan 11, 2021

  • We want const because POSIX shell has readonly. We don't want to lose functionality (or make people use old syntax?)
  • However the whole "declaration" thing is weird for dynamic languages ...
    • especially since we don't have block scope. But should we?
  • idea: const can be dynamic globally, but static locally? Is that too complex?

https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/nested.20procs.20(Notes.20for.20Oil.200.2E8.2E6)

Considerations:

  • Oil blocks, configuration. Const is the COMMON case here.
@andychu
Copy link
Contributor Author

andychu commented Jan 11, 2021

Related #814 -- var at the top level is inconvenient

  • Should we go back to Python-like semantics?
    • we could have ONLY setvar and setglobal ? (instead of the global statement)

Or maybe local consts only? Top level should be setvar ?

@andychu
Copy link
Contributor Author

andychu commented Jan 11, 2021

  • Idea 1: keep things as is.
    • declarations checked statically. mutation of const is a dynamic check, like readonly check
  • Idea 2: const is ONLY static. set/setlocal and setvar can't mutate it, because they're known statically. Others can?

Why we need const: for Oil blocks. Those shouldn't be variables!

@andychu
Copy link
Contributor Author

andychu commented Jan 11, 2021

As of 451ed31

we have static checks for Oil assignment keywords. But there will be an ADDITIONAL dynamic check for const (the one that's already there). I think that's a good compromise.

@andychu andychu changed the title figure out const semantics (locally and globally) document const semantics Jan 14, 2021
@andychu
Copy link
Contributor Author

andychu commented Jan 14, 2021

TODO: test it both locally and globally. I think the dynamic check kicks in globally, but we'll see

@andychu
Copy link
Contributor Author

andychu commented May 14, 2021

Done with 0.8.pre11

@andychu
Copy link
Contributor Author

andychu commented Jul 7, 2021

@andychu andychu closed this as completed Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant