const member function synatx?
renoX
renosky at free.fr
Wed Mar 5 02:40:32 PST 2008
im Wrote:
> I read the page: http://www.digitalmars.com/d/2.0/const3.html
> under section "Const Member Functions"
>
> It didn't give any example, but following the example of 'invariant', it
> should be:
>
> const ReturnType memberFunc(param) {}
>
> I think this is really confusing: is 'const' trying to specify the
> 'ReturnType' or the memberFunc?
As often, this is because C's syntax for variable or prototype declaration suck..
If D used Limbo and Scala syntax for this <function name>(<parameters>):<return value>
then there would be no ambiguity:
const memberFunc(param): ReturnType {}
memberFunc(param): const ReturnType {}
const memberFunc(param): const ReturnType {}
Walter has chosen an inferior syntax in the name of programmers familiarity, this is unlikely to change..
renoX
More information about the Digitalmars-d
mailing list