const and immutable

Steven Schveighoffer schveiguy at yahoo.com
Tue Jul 6 13:58:01 PDT 2010


On Tue, 06 Jul 2010 16:08:21 -0400, Tim Verweij <tjverweij at gmail.com>  
wrote:

> == 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.

Very broken.  It works in a small subset of cases.  Look for this bug to  
be closed when it's fixed (add yourself to the CC of the bug):

http://d.puremagic.com/issues/show_bug.cgi?id=3748

Also, here is a complete overview of how it is supposed to work:

http://prowiki.org/wiki4d/wiki.cgi?action=browse&amp;id=LanguageDevel/DIPs/DIP2&amp;oldid=DiP2

>
> 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?

It's in the book.  I reviewed the book, but I don't have the final copy,  
so I'm not sure how much is discussed.  I remember there were some  
omissions in the copy I reviewed.

-Steve


More information about the Digitalmars-d-learn mailing list