[phobos] Simplify iota for floating-point types?

Robert Jacques sandford at jhu.edu
Fri Dec 24 21:39:51 PST 2010


On Thu, 23 Dec 2010 22:45:07 -0700, Andrei Alexandrescu  
<andrei at erdani.com> wrote:

> On 12/23/10 10:33 PM, Robert Jacques wrote:
>> On Thu, 23 Dec 2010 11:20:24 -0700, Andrei Alexandrescu
>> <andrei at erdani.com> wrote:
>>
>>> Per the recent discussion comparing D with Lua, tests suggest that
>>> iota for double is too slow. This is a necessity if iota is a
>>> bidirectional or random-access range. If we allow it to be a forward
>>> range, then performance would be significantly increased.
>>>
>>> Do you agree with making iota for floating-point types a forward range?
>>>
>>>
>>> Andrei
>>
>> I had thought the major slowdown was using code like 'start + step * i'
>> as opposed to 'current += step', which, although much faster is
>> fundamentally broken, as with floating point numbers x = (x+1), etc. Am
>> I mistaken?
>
> Indeed you are correct.
>
> Andrei

Then may I suggest we keep the correct, but slow, behavior for floats and  
put a note in the docs on the performance/implementation? (Or at least  
internally use reals internally to help mitigate the problem)


More information about the phobos mailing list