preparing for const, final, and invariant

Bill Baxter dnewsgroup at billbaxter.com
Thu May 17 21:36:33 PDT 2007


Walter Bright wrote:
> Bill Baxter wrote:
>> So if you don't use 'in' then the behavior will the the same as not 
>> using anything (or using 'in') in D1.0?
> 
> Right - except that you won't be able to past string literals to them 
> (as string literals will be const).

Ok.  Well that is actually a little nicer than C++ where every reference 
param you don't intend to modify needs to be marked 'const'.  Nicer in 
the sense that 'in' is shorter to type, at least, and in that it won't 
make Don Clugston cringe every time he has to type it.

What about method signatures that want 'this' to be an 'in' param. 
Trailing 'in' like C++?

    void aMethod() in {
        writefln(x, toString);
    }

Seems a little strange but I'm sure I'd get used to it.
I guess const would mean the same thing, though, since 'this' is already 
final and scope doesn't really apply.

--bb



More information about the Digitalmars-d-announce mailing list