Map Purity
jmh530 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 28 08:55:49 PDT 2015
My understanding of pure is that a function labeled pure can only
include pure functions. I've been confused by the fact that a
function calling map (like below) can be labeled pure without any
problems. The only way I can rationalize it is that map really
isn't a function, it's (if I'm understanding it correctly) a
template that creates a template function that calls a struct
template.
auto test_map(T)(T x) pure
{
return x.map!(a => a + a);
}
This is related to
http://forum.dlang.org/thread/ppmokalxdgtszzllzorb@forum.dlang.org?page=1
but maybe my question is more basic.
More information about the Digitalmars-d-learn
mailing list