C++ Ranges proposal for the Standard Library

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 17 21:34:28 PDT 2014


On 10/17/2014 10:46 AM, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Friday, 17 October 2014 at 17:16:29 UTC, Ola Fosheim Grøstad wrote:
>> Accurate is slower, but not this:
>>
>> sum(a)/len(a)
>
> Forgot to point out that the original point with mentioning Python in the thread
> is:
>
> 1. Compiled static languages still have a long way to go with expressiveness.

D has closed that gap quite a bit.


> 2. Generic operations on double will lead to wrong results. What happens if your
> first value is very large? You loose the accumulation of the smaller values, in
> the worst case you only get the first value. Thus you will have to sort the
> values by exponent before accumulating or convert it into a different format.

Or use the much-hated much-misunderstood 80 bit reals!

In any case, just insert a .sort operation. It's still generic.


> So yes, C++ iterators and D ranges are kind of cool, but cannot beat a well
> engineered library and a good mapping to it on the language side. (Python is of
> course not optimal in any way.)

80 bit reals can compensate for a lot of loss-of-precision issues.


More information about the Digitalmars-d mailing list