On Tuesday, 15 October 2013 at 14:15:15 UTC, bearophile wrote:
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
@bearophile: The problem is actually with voldemort. Chain is
implemented as:
auto chain(Arg...)(Args args)
{
static struct Result //Non template struct
{
auto front(); //Non template function in a non-template
struct.
}
}
The problem is that the whole inference things stops at this
level: the attributes of "front" are not infered, so chain is not
pure simply because it isn't a template.
This could be simply solved by making Result a non voldermort
"ChainResult" outside of the body of chain.
I'd do this, but Kenji had mentioned before that he thought the
attributes should be inferred.
So for now, I didn't personally make the effort of doing anything
to fix it myself. But if someone else where make the effort, I'd
review and probably pull.