On Tuesday, 6 March 2012 at 22:48:30 UTC, H. S. Teoh wrote:
Oh? what's wrong with the const?
test10.d(3): Error: function test10.product without 'this' cannot be const/immutable
It works if you put parens on it: pure const(int) product(int[] args) { Without the parenthesis, D wants to apply it to this, like if you write void foo() const {} in C++. The reason here is most the attributes are at the beginning, which is cool because this works: const { void foo() {} int bar() {} } etc. But if you put parens on it, it specifically applies to the int.