digitalmars.D - functions cannot be const or auto
- popka (10/10) Dec 13 2007 Hi all,
- Jarrett Billingsley (4/15) Dec 13 2007 You're using the D1 compiler, not the D2 compiler. Only D2 has constnes...
- Janice Caron (7/8) Dec 13 2007 D1 still has the "const" keyword, which I'm sure is what's confusing
- popka (2/12) Dec 14 2007 Thanks, both of you. I'll continue using version 1 without this feature ...
- Pedro Ferreira (2/16) Dec 14 2007 Wrong. Check the forums, someone has already ported Derelict to DMD 2.
- Janice Caron (3/5) Dec 13 2007 If I had to guess, I'd say you're probably using D version 1, wheras
Hi all, I'm new to D and I've encountered an error message which is confusing me. I am trying to write a 'const' member function, i.e. one which does not modify the object. If I understand correctly, the D syntax for this is: class Foo { const void f() {} } However, this gives me the following error: test.d(2): function test.Foo.f functions cannot be const or auto I have tried this using both DMD and GDC. What am I doing wrong? Many thanks.
Dec 13 2007
"popka" <popka dodgit.com> wrote in message news:fjrshb$1j2j$1 digitalmars.com...Hi all, I'm new to D and I've encountered an error message which is confusing me. I am trying to write a 'const' member function, i.e. one which does not modify the object. If I understand correctly, the D syntax for this is: class Foo { const void f() {} } However, this gives me the following error: test.d(2): function test.Foo.f functions cannot be const or auto I have tried this using both DMD and GDC. What am I doing wrong?You're using the D1 compiler, not the D2 compiler. Only D2 has constness. As far as I know there is no D2-compatible GDC, only DMD.
Dec 13 2007
On 12/13/07, Jarrett Billingsley <kb3ctd2 yahoo.com> wrote:Only D2 has constness.D1 still has the "const" keyword, which I'm sure is what's confusing popka. In D1, the const keyword is used for invariant data. (I'm not making this up! :-) ) I guess Walter was thinking ahead. Anyway, I'm sure that the real problem here is - as /many/ people have pointed out - the default documentation is for D2, but the default download is D1. That's gotta confuse /any/ visitor. (It confused me!)
Dec 13 2007
Janice Caron Wrote:On 12/13/07, Jarrett Billingsley <kb3ctd2 yahoo.com> wrote:Thanks, both of you. I'll continue using version 1 without this feature as it seems Derelict does not support 2.0.Only D2 has constness.D1 still has the "const" keyword, which I'm sure is what's confusing popka. In D1, the const keyword is used for invariant data. (I'm not making this up! :-) ) I guess Walter was thinking ahead. Anyway, I'm sure that the real problem here is - as /many/ people have pointed out - the default documentation is for D2, but the default download is D1. That's gotta confuse /any/ visitor. (It confused me!)
Dec 14 2007
popka Wrote:Janice Caron Wrote:Wrong. Check the forums, someone has already ported Derelict to DMD 2.On 12/13/07, Jarrett Billingsley <kb3ctd2 yahoo.com> wrote:Thanks, both of you. I'll continue using version 1 without this feature as it seems Derelict does not support 2.0.Only D2 has constness.D1 still has the "const" keyword, which I'm sure is what's confusing popka. In D1, the const keyword is used for invariant data. (I'm not making this up! :-) ) I guess Walter was thinking ahead. Anyway, I'm sure that the real problem here is - as /many/ people have pointed out - the default documentation is for D2, but the default download is D1. That's gotta confuse /any/ visitor. (It confused me!)
Dec 14 2007
On 12/13/07, popka <popka dodgit.com> wrote:test.d(2): function test.Foo.f functions cannot be const or auto I have tried this using both DMD and GDC. What am I doing wrong?If I had to guess, I'd say you're probably using D version 1, wheras const proper is only available in D version 2.
Dec 13 2007