const and immutable

Tim Verweij tjverweij at gmail.com
Tue Jul 6 13:08:21 PDT 2010


== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> I'm not positive, but I think the second const applies to the second
> function, I think you meant:
> const Bar& GetBar() const { return mBar; }
Uh, yes, of course. Pff, I feel bad for making such an embarrasing mistake.

> And yes, inout will reduce this to one function:
> ref inout(Bar) GetBar() inout { return mBar; }
> In addition, you do not have to specify the immutable version, therefore
> it actually saves 2 functions.
> That is why it's there :)
Excellent, thanks! So, how is inout "currently very broken" (as noted by Steven
Schveighoffer)? I haven't had the time to try this yet.

I have ordered Andrei Alexandrescu's book "The D Programming Language". Does it
cover inout as well, or is this feature newer than the book?


More information about the Digitalmars-d-learn mailing list