const, final, scope function parameters

Rioshin an'Harthen rharth75 at hotmail.com
Sun May 27 02:42:09 PDT 2007


"janderson" <askme at me.com> kirjoitti viestissä 
news:f3bijn$t1h$1 at digitalmars.com...
> Walter Bright wrote:
> [snip]
>> 2) Having to turn off one of the const, final, or scope, introduces the 
>> need for some sort of "not" keyword, like mutable, !const, !final, etc. 
>> It comes off looking bizarre.
>
> On this point, couldn't it be something like, if you define const, final 
> or scope then the default "const final scope" is removed?
>
> [snip]

I find myself thinking that this might be a better way.

So something akin to this (for in-only parameters)

void foo(int bar) - bar is const final scope
void foo(in int bar) - bar is normal
void foo(const int bar) - bar is const
void foo(final int bar) - bar is final
void foo(scope int bar) - bar is scope
etc. with the combinations

Any specifier of {in|const|final|scope} cancels the const final scope
default of the parameter; mixing "in" with "const", "final" or "scope" is
no problem, since the only use for "in" is to cancel the default of
const final scope, while any of those three cancels the default and
toggles itself on.

(Basically, in and no specifier swap places compared to Walter's
suggestion.) 




More information about the Digitalmars-d mailing list