March 05, 2008 Re: const member function synatx? | ||||
---|---|---|---|---|
| ||||
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
|
March 07, 2008 Re: const member function synatx? | ||||
---|---|---|---|---|
| ||||
Posted in reply to renoX | On Wed, 05 Mar 2008 05:40:32 -0500, renoX wrote: > im Wrote: [snip] > > 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 That syntax would be nicer indeed. We may be able to omit the void return type this way: "print()" instead of "void print()" I personally prefer to move the return type into the function header, but that's another pile of issues. |
Copyright © 1999-2021 by the D Language Foundation