Issue #12133 has been updated by shevegen (Robert A. Heiler).


> where a square bracket indicates boundary inclusion and a parenthesis
> represents boundary exclusion.

I do not like the suggestion but I hope you are not too discouraged.

The reason is ... actually a weird one. I have fairly bad eyesight,
and I'd appreciate if I would not have to look hard between differences
of [] and () for Ranges. There is already, IMO, a lot of additional
meanings in Ruby; Array [], Hash-like notation {}, and to be completely
honest, I'd rather like it if ruby would not add too many hard-to-differ
syntaxes.

I think matz once said that about the lonely person staring at a dot
operator, that the notation foo&.bar() was slightly harder to read
than foo.&bar() or something like that. I actually think that both
notations aren't that easy to read but I agree that one style may be
a bit harder than the other.

Another reason why I dislike the proposal is, well ... take perl.

Perl used a lot of the $ variables such as $: $& and so forth. And
while this can be useful (I use $1 $2 for regexes a lot, for example,
but they are different because the numbers are easy for my mind
to map to) since you don't have to type much, I find them very 
difficult to remember offhand. The english variable names are a
bit easier to remember but also not ... perfect. The reason I
mention this is because your suggestion started with "An intuitive,
approach", and to be honest, to me it is not intuitive at all 
that [] would behave differently than () for Ranges.

I'd much prefer to simply keep the way how Ranges worked in ruby.

----------------------------------------
Feature #12133: Ability to exclude start when defining a range
https://bugs.ruby-lang.org/issues/12133#change-67697

* Author: slash_nick (Ryan Hosford)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
An intuitive, approach would be to allow defining ranges like so:

~~~
[1..10]
[1..10)
(1..10]
(1..10)
~~~

... where a square bracket indicates boundary inclusion and a parenthesis represents boundary exclusion. The syntax there is obviously not going to work, but it demonstrates the idea.

A more feasible, still intuitive, solution might look like the following

~~~
(1..10)                # [1..10]
(1...10)               # [1..10) ... Alternatively: (1..10).exclude_end
(1..10).exclude_start  # (1..10]
(1...10).exclude_start # (1..10) ... Alternatively: (1..10).exclude_start.exclude_end
~~~

For consistency, I think we'd also want to add `#exclude_start?` & `#exclude_end` methods.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>