should chain be pure

bearophile bearophileHUGS at lycos.com
Tue Oct 15 07:15:14 PDT 2013


Daniel Davidson:

> If you are agreeing that chain should be pure and it is just 
> following all the calls and making all of them pure, until that 
> happens by the professionals - is there a casting solution so I 
> can fake a pure and move on?

chain is a template, and in Phobos often templates are not 
annotated with pure/nothrow, the compiler infers those attributes.

Regarding your code, perhaps you can put your call in an impure 
delegate and than cast it, but D has no direct means to "cast" 
purity, because it's highly unsafe and it's against the idea of 
having purity in the language.

So I suggest to replace the pure in your function/method tree 
with /*pure*/, and later fix the code if/when chains becomes pure.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list