From: Hugh Sasse Staff Elec Eng Date: 2003-02-13T01:58:24+09:00 Subject: Re: Range#length?!?!? On Thu, 13 Feb 2003, ahoward wrote: > On Thu, 13 Feb 2003, Hugh Sasse Staff Elec Eng wrote: > > > But then, for "range" itself you get results including: > > > > 1. The maximum extent or distance limiting operation, action, or [...] > > touche! ;-) > > i think it's not quite fair though, as Range is defined as a SET of values in > the pickaxe (which, let's face it, is essentially a language specification to > most of us). It is used that way, but it is a description of what exists, rather than the basis for the language design. Is 'post hoc' the phrase here? > > > each of which include "distance" in the definition of range. > > range.distance would mean the distance of the distance? :-) > > by that logic 'distance.size' does not make much sense either. You can talk about the size of a distance, if it is small or large... Maybe Range.length? Does this really mean we need another mixin like Enumearable called Differencable (not to be confused with differentiable, which implies calculus!) so that things which can be ordered but not subtracted and things which can be ordered AND subtracted behave appropriately? This use of length() might (cognitively) interfere with Array.length, though. Range.span(), perhaps? > > > Except that floats aren't reals, so are not infinitely precise, so > > there is a finite number between two values. > > technically, with today's technology yes. abstractly though, they ARE reals > and nearly always have that semantic meaning. if their finiteness could be > counted on, they would be used to control for loops, but no one does that do > they? No, but it would allow some resolution to this without getting into orders of infinity. But it would be up to Matz, and there is a stronger case for "pretending" they ARE reals. > > > > Ranges can be constructed using objects of any type, as long as the objects > > > can be compared using their <=> operator and they support the succ method to > > > return the next object in sequence. > > > .... > > > so a Range HAS a start and end, but it IS a SET. all that is required to be a > > > set is to implement <=> and succ, which Floats do. using your logic what > > > > Really? > > > you are correct - but i was merely quoting the pickaxe. the point was that Yes, but I was surprised by this reference to succ, didn't notice it in this way before. I think this is possibly an overspecification for what a range is, given the float case, though any other description would complicate the text somewhat. > their is no implication that the objects in a Range support '+' or '-', etc. > rather the implication is only that they are an ordered set - nothing more - > and ordered does not imply finite nor the applicability of mathmatical > operators. Agreed. > > [...] > > > surely it should be 'just a little' bigger than (0.0 .. 42.0).size right? > > > > smaller. ... excludes the end. This has always puzzled me, that > > the longer gap ('..' vs '...') is the shorter interval, but it's way > > too late to change now, and knowing what I know of Matz's work, > > there's going to be a VERY good reason for this! > > again, i miswrote (only ONE cup of cafe so far!) but we are on the same page No problem, just thought it might help to flag this up as I keep making this particular mistake. "Experience is the ability to recognise a mistake when you make it again" to quote /usr/games/fortune. > here. you didn't address the question though - iff a range of floats is NOT > Infinity then what would the return value be for > > (0.0 .. 42.0).size > > and > > (0.0 ... 42.0).size > > it is impossible to define size using '-' and have this make any sort of > sense since (0.0 .. 42.0) > (0.0 ... 42.0)! This is like open and closed sets. If the range is a set, then you know what the largest value in the set is, in the first case it is 42.0, in the second it is something a bit smaller which is probably architecture dependent. It might not be a useful value to obtain, but it still has meaning. How the machine obtains this value is another thing -- it would be silly to represent a Float range as a lump of virtual memory with all those floats in it, "Oh, and throw away the 42.0 -- we don't need that!". Also this is complicated because the space between two floats will change as the magnitude gets large. "The devil is in the detail". > > -a > Hugh