-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
ysh breaking: Replace 1 .. 5 range syntax with 1 ..< 5 half open and 1 ..= 5 closed range #2096
Comments
I have thought about the Or I'm not sure it's inconsistent though, I think It's also consistent with slicing - |
With this combination, reading a
Well, that's exacltly the problem, assumed meanings, off by one (value and/or background). Half-open intervals seem useful e.g. for iterating over them (like slicing a whole bread). Whereas generally specifying a range or slice in math or spoken language seems to rely on symmetric definitions by default. Half-open intervals seem to have come as a shortcut in (overly) programming-centered programming languages, then they believed: In general, the "implicitly half-open by default" seems error-prone and easily misleading. (Especially for shell user's that can't be assumed to be full time programmers.) So, a possible explicit solution maybe?: |
|
{1..2} vs. (1..2)
With your feedback I've now reworked the orig. issue summary and added a list of inconsistencies. Please have look. I think the use of |
Yeah I have noticed the inconsistency between shell's (I think shell is a little broken because But yes I can see that from a shell user's POV, this could be confusing/inconsistent. From a Python/JS POV, it's not It is a valid point |
Hm actually I discovered Ruby is consistent with shell, and inconsistent with Rust/JS/Python:
So yeah this is probably a good reason to change it I think a stricter version of Swift and Rust would be good, with https://doc.rust-lang.org/reference/expressions/range-expr.html We can force you to choose it, not provide We have some ruby-like features, so it is probably good not to "annoy" people used to ruby (and shell of course) |
Yes, not to "annoy" non-shell users is just as important. I think an idea that already came up, when I figured out a clean up path for the syntax and interaction (python users are accustomed to) around mutability/aliasing (#1831), was having some If there really is a need for an option like |
Well I am leaning toward just having So there is no ambiguity for anyone, and no need for any options (which are necessary sometimes, but cause complexity) That seems like the simplest approach |
Yes, I agree, no need for any strict_ option when |
@PossiblyAShrub like this, so we should do it It will be a breaking change, but we'll have an OILS-ERR hint for |
BTW: I had stumbled over the Top results: I wonder why ysh is so much slower than python. From the 2024 blog overview (https://www.oilshell.org/blog/2024/09/project-overview.html), what Nim is missing seems only a Command-language feature, and external-interface representing procs?
|
Hm, noticed you say "hint". As minimal error messages are printed, it might actually make good sense to refer to the optional texts as "OILS-HINT-xxx" [makes it also much more naturally to have them shipped in a separate -doc tarball/package (https://github.com//issues/2095)]. |
{1..2} vs. (1..2)
This is now done -- @PossiblyAShrub agreed with this feedback :-) Will be out for the next release I think some of them could be OILS-HINT, but it's not worth having 2 things, or worth changing now The googling for OILS-ERR already works -- we tested it :) |
Thanks, both!
Sure, however it's not instantly presented without extra steps, and not in offline environments, so still looking forward to get the full hints/errors back by installing some oils-docs package locally. |
The implicit, not fully consistent, and unsymetrical inclusive/exclusive behavior of
..
ranges (and slices) seems just asking for bugs.The syntax ambiguity of
..
is problematic:After reading:
https://www.reddit.com/r/ProgrammingLanguages/comments/x8xtou/asking_for_opinions_on_the_best_way_to_specify_an/
Maybe a solution like the following could work in ysh expressions as a consistent concession that still allows for short enough common cases:
(Maybe the common spoken default meaning could be seen as usually being inclusive on the first (left) border side given?)
..
..=
..<
<..=
<..<
The text was updated successfully, but these errors were encountered: