From: shevegen@... Date: 2018-05-02T14:10:12+00:00 Subject: [ruby-core:86841] [Ruby trunk Feature#14724] chains of inequalities Issue #14724 has been updated by shevegen (Robert A. Heiler). > And implementing it even for other operators would silently break > existing code which I don't think is justifiable in this case. > After all Matz will decide, but imho this should not be implemented. I do not know how matz will decide; I personally am neutral here. I really have no problem either way. I think it may be discussed at the next meeting; Martin D��rst already added it (I think). As for incompatibilities, in principle this could fit to ruby 3.x but I think matz also said somewhere that he may not necessarily want to add (too many?) incompatible changes from 2.x to 3.x. I am not sure if I quote him correctly, but this is what I have gathered. So 2.x to 3.x will not be like 1.8.x to 1.9.x, if I understood it correctly. On a side note, if we ignore the specific versions, we could also ask the question differently, for any feature: :) - if matz would create a new language, like ruby, but give it a different name, would this or that feature be part of the language? I really have no idea in regards to the feature here, but I think depending on that answer, this may or may not have some merit (e. g. if we ignore the situation of backwards incompatibility, since that situation often means that a change may not happen even if it could have happened if a ruby-like language were created anew today. Not sure if I managed to get across what I was trying to say ... but again, I am completely neutral on this, not having a pro or con opinion. I am more looking at the mjit-related changes. :D) ---------------------------------------- Feature #14724: chains of inequalities https://bugs.ruby-lang.org/issues/14724#change-71805 * Author: gotoken (Kentaro Goto) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- In mathematics, chain of inequations is a shorthand notation for the conjunction of several inequations involving common expressions. For example, `a < b <= c` for `a < b && b <= c` Chain notation makes code clearer, in particular, long common expression cases will be so. E.g., ``` cur.to_i - 2 <= timeval.tv_sec <= cur.to_i ``` is easier to read than ``` cur.to_i - 2 <= timeval.tv_sec && timeval.tv_sec <= cur.to_i ``` because in the latter case we have to verify whether `timeval.tv_sec` is common or not by eyes. Current syntax allows but redefining builtin methods are considered not practical. So here I request as a new syntax for the chains. ### Use cases (applicable conjunctions) lib/matrix.rb: ```ruby unless 0 <= column && column < column_count ``` lib/time.rb documents: ```ruby # block. For example: # # Time.parse(...) {|y| 0 <= y && y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y} ``` spec/ruby/optional/capi/bignum_spec.rb: ```ruby raise "Bignum#coerce returned Fixnum" if fixnum_min <= n && n <= fixnum_max ``` test/fiddle/test_import.rb: ```ruby assert(cur.to_i - 2 <= timeval.tv_sec && timeval.tv_sec <= cur.to_i) ``` tool/jisx0208.rb: ```ruby unless 0x8140 <= sjis && sjis <= 0xFCFC ``` -- https://bugs.ruby-lang.org/ Unsubscribe: