digitalmars.D.learn - Type qualifiers - inout error
- Claudiu Verdes (19/19) Jun 16 2011 Hi,
- bearophile (5/8) Jun 16 2011 I think there isn't one. Anything goes! ;-)
- Steven Schveighoffer (16/20) Jun 17 2011 Yes, a better example would be:
Hi, I'm new to D and trying to follow Alexandrescu's TDPL code examples I came across an error on the code below: class A { inout(int) val() inout { return _val; // error - see below } private int _val; }; The compiler (dmd v2.052) complains on the marked line with the message "Error: inout on return means inout must be on a parameter as well for inout inout(int)()". What am I doing wrong? TDPL has a very similar example... Regards, Claudiu P.S. Is there a netiquette (a la C++ FAQ lite) about posting on this forum that I should be aware of?
Jun 16 2011
Claudiu Verdes:What am I doing wrong? TDPL has a very similar example...I think this TDPL example is not good. And generally inout is not fully implemented in D yet.P.S. Is there a netiquette (a la C++ FAQ lite) about posting on this forum that I should be aware of?I think there isn't one. Anything goes! ;-) Bye, bearophile
Jun 16 2011
On Thu, 16 Jun 2011 22:12:49 -0400, bearophile <bearophileHUGS lycos.com> wrote:Claudiu Verdes:Yes, a better example would be: class A { ref inout(int) val() inout { return _val; } private int _val; } inout is only relevant if the data type being returned has a reference in it, because a value-only type is implicitly castable to any constancy (const, immutable, or mutable). As bearophile says, inout is not properly implemented yet. -SteveWhat am I doing wrong? TDPL has a very similar example...I think this TDPL example is not good. And generally inout is not fully implemented in D yet.
Jun 17 2011