Beware, Range exists in other languages (python, etc..). We should check if they correspond to a Smalltalk Interval or a mathematical Interval. If they correspond to a Smalltalk Interval, that will be one more un-necessary trap.
Note that we rarely use Interval, we just use #to: or #to:by:, so we could as well rename Interval->Range. And postpone creation of Mathematical Interval which is most likely unused in kernel image. Nicolas 2012/12/16 Stéphane Ducasse <[email protected]>: > I agree so we should introduce Range. > Did not you or camillo started to have Range? > It can be a really nice class. > > Stef > On Dec 16, 2012, at 4:55 PM, Igor Stasenko wrote: > >> So, to my sense a behavior of Interval is overloaded.. >> it tries to be too many things at once: >> - be an interval in math sense (which is infinite set if used for Real >> numbers) >> - be a "collection" of numbers which you can enumerate (implies that >> it is finite). >> >> to me, i would be much happier if we could have two different and >> non-intersecting entities: >> >> - Enumeration. This one indeed can be used as a collection. i.e. >> "give me all integer numbers lying between values A and B, count each >> C-th number" >> Like that, >> (1 to: 1.5 by: 1) is enumeration which contains a single element. >> and #last should be = 1 >> >> - Interval (Range). A pure interval in math sense: defines a Set of >> numbers lying between numbers A and B, inclusive, where A <= B. Not >> enumerable, therefore no 'step' variable, instead what it could have, >> is flags to indicate whether interval endpoints included into interval >> or not.. i.e. (a,b) vs [a,b] vs [a,b) vs (a,b]. >> >> Not supporting enumeration (no #do: , no #add: no #at: etc). You can, >> however intersect, merge or diff two intervals etc.. same operations >> which you doing on sets (but that would require another entity - >> interval set). And of course, you can test whether some number lies >> within given interval or not. >> >> The reason i started this topic is because some code were using >> 'range' for variables which holding intervals.. >> Now what you think is more appropriate protocol for something called >> 'range', this: >> >> x := range first >> y := range last >> >> or this: >> >> x := range start >> y := range end >> >> >> -- >> Best regards, >> Igor Stasenko. >> > >
