digitalmars.D.learn - Type qualifiers - inout error
- Claudiu Verdes <claudiu.verdes gmail.com> Jun 16 2011
- bearophile <bearophileHUGS lycos.com> Jun 16 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Jun 17 2011
--001485f6d9fe3223ef04a5dc4103
Content-Type: text/plain; charset=ISO-8859-1
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?
--001485f6d9fe3223ef04a5dc4103
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,<div><br></div><div>I'm new to D and trying to follow Alexandrescu&#=
39;s TDPL code examples I came across an error on the code below:</div><div=
<br></div><div><div>class A</div><div>{</div><div><span class=3D"Apple-tab=
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>{</di=
v><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>re=
turn _val; // error - see below</div><div><span class=3D"Apple-tab-span" st=
yle=3D"white-space:pre"> </span>}</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>priva=
te int _val;</div><div>};</div></div><div><br></div><div>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)()&q=
uot;.=A0</div>
<div><br></div><div>What am I doing wrong? TDPL has a very similar example.=
..</div><div><br></div><div>Regards,</div><div>Claudiu</div><div><br></div>=
<div>P.S. Is there a netiquette (a la C++ FAQ lite) about posting on this f=
orum that I should be aware of?</div>
<div><br></div>
--001485f6d9fe3223ef04a5dc4103--
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: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.
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. -Steve
Jun 17 2011









bearophile <bearophileHUGS lycos.com> 