The new, new phobos sneak preview
Don
nospam at nospam.com
Mon Apr 13 11:38:39 PDT 2009
Andrei Alexandrescu wrote:
> Lars Kyllingstad wrote:
>> Michel Fortin wrote:
>>> On 2009-04-12 11:09:51 -0400, Lars Kyllingstad
>>> <public at kyllingen.NOSPAMnet> said:
>>>
>>>> Andrei Alexandrescu wrote:
>>>>> Lars Kyllingstad wrote:
>>>>>> I think isInfinite!() should be called isInfiniteRange!(). The
>>>>>> current name is, in my opinion, too general.
>>>>>
>>>>> I'm undecided about this (and similar cases). isInfinite sits
>>>>> inside std.range, so std.range.isInfinite is clear and
>>>>> std.range.isInfiniteRange feels redundant. On the other hand, I
>>>>> don't want to use too common symbols because then the user will be
>>>>> forced to prefix them whenever they clash.
>>>>
>>>> I'm not too worried about name clashes, I just think it sounds
>>>> wrong. If R is a range with infinitely many elements, I think it's
>>>> more correct to say "R is an infinite range" than to say "R is
>>>> infinite".
>>>>
>>>> As an example of what I mean, let the range R be the sequence 1,
>>>> 1/4, 1/9, ...:
>>>>
>>>> alias Sequence!("1/(n*n)", 1) R
>>>>
>>>> Then, isInfiniteRange!(R) should obviously yield true. From a
>>>> mathematical standpoint, I think the result of isInfinite!(R) is
>>>> less obvious. Yes, the range has infinitely many elements, but none
>>>> of them are infinite, nor is their sum infinite.
>>>
>>> Perhaps it should be renamed to isUnbounded then.
>>
>> ...except that my example, and indeed any range produced by sequence,
>> recurrence, etc. are bounded at one end. Thus the term "infinite
>> range" is more precise, and fits in well with the mathematical terms
>> "infinite series" and "infinite sequence". Just not "infinite" alone. :)
>>
>> -Lars
>
> Finally! I was waiting for someone to make this point. "Bounded" would
> be closer to "having values within a finite interval".
>
> Andrei
There's a funny thing with floating-point numbers, though.
The range [real.max, real.infinity] contains only two elements, one of
which is infinity. Is that an infinite range?
It would be helpful to distinguish "contains arbitrary many
elements"/"length is undefined" from "contains the point at
infinity"/"includes the maximum representable element for this type".
More information about the Digitalmars-d
mailing list