digitalmars.D - const { ... } no workie?
- AEon (14/14) Mar 15 2005 // Const Attribute example from manual
- Manfred Nowak (5/6) Mar 15 2005 [...]
- AEon (4/9) Mar 15 2005 Could it be that I am doing something wrong with the compile options?
- Ben Hinkle (4/14) Mar 15 2005 posting a complete example would help. It works fine for me, too, no mat...
- AEon (23/26) Mar 15 2005 Right, I had the example running with several other examples as well, no...
- clayasaurus (4/44) Mar 15 2005 (dmd .118 linux)
- AEon (5/8) Mar 15 2005 /me (dmd .118 windows)
- randomnewbie (2/28) Mar 15 2005 you can use const with D?
- Jarrett Billingsley (5/6) Mar 15 2005 Yes, just not in all the ways that you can in C++. C++ allows you to, f...
- Stewart Gordon (8/26) Jun 21 2005 Yes. That the code snippet on that page isn't within a function. The
// Const Attribute example from manual (http://www.prowiki.org/wiki4d/wiki.cgi?LanguageSpecification/Original) const int foo = 7; const { // Line 183 double bar = foo + 6; } // test.d(183): basic type expected, not { // test.d(183): no identifier for declarator int // test.d(183): semicolon expected, not '{' // --- errorlevel 1 Is the const { } syntax not yet implemented in dmd 0.118, or did I miss something? AEon
Mar 15 2005
AEon <AEon_member pathlink.com> wrote: [...]// test.d(183): basic type expected, not {[...] Not confirmed. dmd 0.118 compiles the example lines. -manfred
Mar 15 2005
Manfred Nowak says...AEon wrote: [...]Could it be that I am doing something wrong with the compile options? dmd -c -w -O -release -inline -I. test.d AEon// test.d(183): basic type expected, not {[...] Not confirmed. dmd 0.118 compiles the example lines.
Mar 15 2005
posting a complete example would help. It works fine for me, too, no matter what options I throw at the compiler. "AEon" <AEon_member pathlink.com> wrote in message news:d16ts4$1db5$1 digitaldaemon.com...Manfred Nowak says...AEon wrote: [...]Could it be that I am doing something wrong with the compile options? dmd -c -w -O -release -inline -I. test.d AEon// test.d(183): basic type expected, not {[...] Not confirmed. dmd 0.118 compiles the example lines.
Mar 15 2005
Ben Hinkle says...posting a complete example would help. It works fine for me, too, no matter what options I throw at the compiler.Right, I had the example running with several other examples as well, now I placed the example in a seperat file: consttest.d <code> import std.c.stdio; int main (char[][] args) { // Const Attribute example from manual const int foo = 7; const { // Line 10 double bar = foo + 6; } return 0; } </code> I still get the same error in line 10 though:dmd consttest.dconsttest.d(10): basic type expected, not { consttest.d(10): no identifier for declarator int consttest.d(10): semicolon expected, not '{' Hope that helps. AEon
Mar 15 2005
AEon wrote:Ben Hinkle says...(dmd .118 linux) I get the same errors. Why not just use const double bar = foo + 6;posting a complete example would help. It works fine for me, too, no matter what options I throw at the compiler.Right, I had the example running with several other examples as well, now I placed the example in a seperat file: consttest.d <code> import std.c.stdio; int main (char[][] args) { // Const Attribute example from manual const int foo = 7; const { // Line 10 double bar = foo + 6; } return 0; } </code> I still get the same error in line 10 though:dmd consttest.dconsttest.d(10): basic type expected, not { consttest.d(10): no identifier for declarator int consttest.d(10): semicolon expected, not '{' Hope that helps. AEon
Mar 15 2005
In article <d17br2$1tt6$1 digitaldaemon.com>, clayasaurus says...(dmd .118 linux) I get the same errors. Why not just use const double bar = foo + 6;/me (dmd .118 windows) Actually I don't really have a problem with the above, just surprised my that the compile test failed. Well at least on my setup. AEon
Mar 15 2005
Ben Hinkle wrote:posting a complete example would help. It works fine for me, too, no matter what options I throw at the compiler. "AEon" <AEon_member pathlink.com> wrote in message news:d16ts4$1db5$1 digitaldaemon.com...you can use const with D?Manfred Nowak says...AEon wrote: [...]Could it be that I am doing something wrong with the compile options? dmd -c -w -O -release -inline -I. test.d AEon// test.d(183): basic type expected, not {[...] Not confirmed. dmd 0.118 compiles the example lines.
Mar 15 2005
"randomnewbie" <bob bob.com> wrote in message news:d178dn$1q21$1 digitaldaemon.com...you can use const with D?Yes, just not in all the ways that you can in C++. C++ allows you to, for example, declare function parameters as const, thus making them unmodifyable. D doesn't. However, const variable declarations are allowed.
Mar 15 2005
AEon wrote:// Const Attribute example from manual (http://www.prowiki.org/wiki4d/wiki.cgi?LanguageSpecification/Original) const int foo = 7; const { // Line 183 double bar = foo + 6; } // test.d(183): basic type expected, not { // test.d(183): no identifier for declarator int // test.d(183): semicolon expected, not '{' // --- errorlevel 1 Is the const { } syntax not yet implemented in dmd 0.118, or did I miss something?Yes. That the code snippet on that page isn't within a function. The attribute { ... } syntax applies at only module or class/struct/union level. But there does seem to be something missing from the spec here.... Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jun 21 2005