From: gotoken@... (GOTO Kentaro) Date: 1999-07-05T09:35:40+09:00 Subject: [ruby-talk:00430] Re: New feature for Ruby? Hi, In message "[ruby-talk:00429] Re: New feature for Ruby?" on 99/07/03, Clemens Hintze writes: >But I perhaps lack ability to write articles so that a magazin would >publish it! But nevertheless, I will try it someday :-) I long for your articles! By the way, I also would like to translate Matz and his collaborator's book about Ruby which will be published in near future in Japan. But I need a collaborator who correct my Engrish if I'm permitted to translate. >But Ruby already have magical increment of Strings, means String#succ! >And if I do a `"".succ' I will get an `"\377"'. As I didn't consider >that behavior as the one one would expect, I have patched String#succ, >so that it would raise an exception. That maybe important. I think succ is allowed to be non one-to-one mapping, such that, str1.succ == str2.succ for str1 != str2. But either str.pred.succ == str or str.succ.pred == str should be held for arbitrary String str, I think. >ATTENTION PLEASE: If Interval would define Interval#===, it would have >a slight other task than Range#===! > >Interval#=== should checks, whether a certain value would be contained >by that interval or not. That means > > interval(0,100,2) === 2 # true > interval(0,100,2) === 1 # false > >The second example would be false, as the interval is [0, 2, 4, ..., >100] and there is no element 1. For such objects, I feel a suitable name is `Sequence' rather than Interval. The name Sequence itself means descrete series, i.e., enumerable and one dimensional. But Interval reminds me and mathematicians so general region as it may be use to a continuum or a higher dimensional structure. Other opinions? >>However I feel that makes Interval to become closer to Range. > >You're right! But it is not my desire to make Interval as different as >possible to Range. If we would obey that rule all the time, it would >not be necessary to have Fixnum and Integer. Fixnum would enough, >right? Hummm, Fixnum is distinct from Integer in its functions, especially, the spacial cost. I've not recognized yet such major difference between Range and Interval. I feel some of problems or restrictions on Range seems to able to be solve by extending Range. I'd like to listen other persons' (including Matz's again) opinions. >>Yes! I understand that. In this point of view, I want also >>membership specified region class for non-enumerable objects. But it >>will be defined in the project anyway. In the numerical scene such >>ranges appear very often. > >Perhaps I have not grasp your point at whole. Would you be so kind to >explain your last paragraph again? Well, we numerical experimenters very often use regions on Float, Time or some mathematical/physical quantiteis in order to define domain/range of functions or data. And sometimes, we want to apply set theoretical union, intersection or subtraction of them for readability. Of cource, combinating of inequation-tests can be use to do equvalent tasks but long conditions are too intensinal and blur extensional meanings. For example dom = interval(1.01, 2.43) - interval(1.981, 1.9842) ... raise "domain error" unless x.belongs?(dom) is easy to read. -- gotoken