Generic code: @autoconst, @autopure, @autonothrow

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Aug 30 12:24:08 PDT 2010


On 8/30/10 14:16 PDT, Tomek Sowiński wrote:
> Dnia 30-08-2010 o 21:10:10 Tomek Sowiński <just at ask.me> napisał(a):
>
>> How about reduce!fun(range)? It's pure/nothrow when fun is
>> pure/nothrow. Plenty of std.algorithm would benefit.
>
> Eh, nevermind. popFront() must mutate the range so it can't be pure.
> Need to get some sleep...

It can still be nothrow depending on input, which makes a solid point. 
Arguments against qualifier/attribute propagation based on sheer 
semantics ("it's abs so it must be pure") break badly in the face of 
higher-order functions.

It's pretty clear we need an attribute propagation mechanism if we want 
e.g. to make Phobos const-aware.


Andrei


More information about the Digitalmars-d mailing list