bearophile wrote:
>> @optional_tag(isPure!F, pure) int[] map(F)(F f, int[] data) {
>> int[] res;
>> foreach (x; data)
>> res ~= f(x);
>> return res;
>> }
>
> This may not suffice to correctly tell apart strong pure functions from weak
> pure ones...
>
Untested:
==============================8<------------------------------
template optionalTag (bool test, char[] tag) {
static if (test)
const char[] optionalTag = tag;
else
const char[] optionalTag = "";
}
template bool isPure(F)() {
return functionAttributes!F & FunctionAttribute.PURE;
}
mixin(optionalTag!(isPure!F, "pure")) int[] map(F)(F f, int[] data) ...
------------------------------>8==============================
Of course, this suffers from the ugly syntax for string mixins...
Jerome
--
mailto:[email protected]
http://jeberger.free.fr
Jabber: [email protected]
signature.asc
Description: OpenPGP digital signature
