Compile-time constness is waaay to strict!
asd
a at sd.invalid
Fri Jul 24 17:27:06 PDT 2009
I've got D2 code:
> template ObjcMethodSelectorCheck(string sel, A...) {
> const n = countMethodArguments(sel);
and:
pure static uint countMethodArguments(string name) {
if (name.length == 0) return 0;
if (name[0] == ':') return 1+countMethodArguments(name[1..$]);
return countMethodArguments(name[1..$]);
}
Original version of this method was pure too, but used count++. Fine, maybe compiler wasn't smart enough to understand that, but now I've rewritten it in purely functional style, and it's still not "constant" enough!
objc/method.d(54): Error: cannot evaluate countMethodArguments(ToSetterSelector) at compile time
objc/method.d(57): Error: expression 1u != countMethodArguments(ToSetterSelector) is not constant or does not evaluate to a bool
More information about the Digitalmars-d
mailing list