preparing for const, final, and invariant
Reiner Pope
some at address.com
Sun May 20 23:19:03 PDT 2007
Walter Bright wrote:
> Regan Heath wrote:
>> Why not make this implicit 'in' parameter 'scope const final' avoiding
>> the need to explicity say 'in' everywhere?
>
> It's a good idea, but then there needs to be some way to pass a mutable
> reference. Such as:
>
> class C { int x; }
> void foo(C c)
> {
> c.x = 3;
> }
>
> That doesn't work if 'const' is the default. Using out or inout doesn't
> work either, as those have slightly different semantics (an extra level
> of indirection).
At the risk of aggravating more people by adding Yet Another Keyword,
how about 'const scope final' by default, with some negative keywords to
undo it.
Like, say, unconst and unscope:
void foo(unconst C c)
{
c.x = 3;
}
or why not use the ! operator, which already means 'not':
void foo(!const C c)
{
c.x = 3;
}
Cheers,
Reiner
More information about the Digitalmars-d-announce
mailing list