preparing for const, final, and invariant

Chris Nicholson-Sauls ibisbasenji at gmail.com
Thu May 17 23:41:16 PDT 2007



Bill Baxter wrote:
> 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);
>    }

Assuming they haven't changed, this would break pre-conditions.

> 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

Since this may have its uses, and so long as the meaning is very clear, I could live with 
'const' in that position.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-announce mailing list