www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - learning D. Experienced issue very quickly.

reply "Mark" <section91 yahoo.com> writes:
Yeah I bought the book recently and ran into an issue very 
quickly into it. But this error I keep getting keeps bugging me. 
Could really use an explanation on why its not compiling. Here is 
the code.

/*
   Compute heights in centimeters for a range of heights
   expressed in feet and inches
*/
import std.stdio;

void main() {
   // values unlikely to change soon
   immutable inchPerFoot = 12;
   immutable cmPerInch = 2.54;

   // loop'n write
   foreach (feet; 5 .. 7) {
     foreach (inches; 0 .. inchPerFoot) {
       writeln(feet, "'", inches, "''\t",
         (feet * inchPerFoot + inches) * cmPerInch);
     }
   }
}


Here is the error I keep getting every time I try to compile:

(13): found '..' when expecting ')'
(13): found ')' when expecting ';' following statement
(14): found '..' when expecting ')'
(14): found ')' when expecting ';' following statement
Apr 18 2012
next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 18 Apr 2012 09:10:46 -0400, Mark <section91 yahoo.com> wrote:

 Yeah I bought the book recently and ran into an issue very quickly into  
 it. But this error I keep getting keeps bugging me. Could really use an  
 explanation on why its not compiling. Here is the code.

 /*
    Compute heights in centimeters for a range of heights
    expressed in feet and inches
 */
 import std.stdio;

 void main() {
    // values unlikely to change soon
    immutable inchPerFoot = 12;
    immutable cmPerInch = 2.54;

    // loop'n write
    foreach (feet; 5 .. 7) {
      foreach (inches; 0 .. inchPerFoot) {
        writeln(feet, "'", inches, "''\t",
          (feet * inchPerFoot + inches) * cmPerInch);
      }
    }
 }


 Here is the error I keep getting every time I try to compile:

 (13): found '..' when expecting ')'
 (13): found ')' when expecting ';' following statement
 (14): found '..' when expecting ')'
 (14): found ')' when expecting ';' following statement
This compiles and runs on my system. Are you using D1? Please use the latest D (a.k.a D2) compiler. The book does *not* cover D1 at all. If you are, please give more detail (OS, which compiler you are using). -Steve
Apr 18 2012
prev sibling next sibling parent reply simendsjo <simendsjo gmail.com> writes:
On Wed, 18 Apr 2012 15:10:46 +0200, Mark <section91 yahoo.com> wrote:

 Yeah I bought the book recently and ran into an issue very quickly into  
 it. But this error I keep getting keeps bugging me. Could really use an  
 explanation on why its not compiling. Here is the code.

 /*
    Compute heights in centimeters for a range of heights
    expressed in feet and inches
 */
 import std.stdio;

 void main() {
    // values unlikely to change soon
    immutable inchPerFoot = 12;
    immutable cmPerInch = 2.54;

    // loop'n write
    foreach (feet; 5 .. 7) {
      foreach (inches; 0 .. inchPerFoot) {
        writeln(feet, "'", inches, "''\t",
          (feet * inchPerFoot + inches) * cmPerInch);
      }
    }
 }


 Here is the error I keep getting every time I try to compile:

 (13): found '..' when expecting ')'
 (13): found ')' when expecting ';' following statement
 (14): found '..' when expecting ')'
 (14): found ')' when expecting ';' following statement
Are you using the D1 compiler..? It works on dmd 2.057,8 and 9 at least. Just write dmd, and look at the top for the compiler version.
Apr 18 2012
parent reply "Mark" <section91 yahoo.com> writes:
 Are you using the D1 compiler..? It works on dmd 2.057,8 and 9 
 at least.
 Just write dmd, and look at the top for the compiler version.
look at that. it says D1. I downloaded both D1 and D2. Better get rid of D1 then. I feel like such an idiot. THank you for the help.
Apr 18 2012
next sibling parent simendsjo <simendsjo gmail.com> writes:
On Wed, 18 Apr 2012 15:24:12 +0200, Mark <section91 yahoo.com> wrote:

 Are you using the D1 compiler..? It works on dmd 2.057,8 and 9 at least.
 Just write dmd, and look at the top for the compiler version.
look at that. it says D1. I downloaded both D1 and D2. Better get rid of D1 then. I feel like such an idiot. THank you for the help.
It's an easy mistake to make - at least now that D refers to D2, while it used to refer to D1 :)
Apr 18 2012
prev sibling next sibling parent Mirko Pilger <pilger cymotec.de> writes:
 I feel like such an idiot.
don't worry. you're not the first and not the last being confused by this.
Apr 18 2012
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Mark:

 look at that. it says D1. I downloaded both D1 and D2. Better 
 get rid of D1 then. I feel like such an idiot. THank you for 
 the help.
You aren't an idiot, it's not your fault. In some months D1 compilers will be buried deeply in some sites, so your problem will (mostly) stop happening to new people. Having a well debugged compiler is most important, but also such simple "packaging/access" issue shouldn't be ignored. Bye, bearophile
Apr 18 2012
prev sibling parent reply "Paul" <phshaffer gmail.com> writes:
On Wednesday, 18 April 2012 at 13:10:47 UTC, Mark wrote:
 Yeah I bought the book recently and ran into an issue very 
 quickly into it. But this error I keep getting keeps bugging 
 me. Could really use an explanation on why its not compiling. 
 Here is the code.
Mark I started a thread along this line of reasoning. In my case it was the other way around. I made sure I downloaded D2 but found a code snippet for D1 (I think). I'm starting to realize this is probably an issue with free examples, tutorials, etc. The code isn't posted with comments or context as how it will compile. If I ever start offering my code on the web I'm going to put in the first comment line of the source code what context it compiled and ran under. e.g. DMD v2.058/Phobos/Win32/etc. Then if some newbie slacker like us is looking at the code 2 years from now, he will have some idea of whether he should try it. And if it doesn't compile, he can say "well that example was v2.058/Win32 and this is V4.01/Linux64 that I am running." ....and not get frustrated.
Apr 18 2012
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Apr 19, 2012 at 12:51:21AM +0200, Paul wrote:
 On Wednesday, 18 April 2012 at 13:10:47 UTC, Mark wrote:
Yeah I bought the book recently and ran into an issue very quickly
into it. But this error I keep getting keeps bugging me. Could really
use an explanation on why its not compiling. Here is the code.
Mark I started a thread along this line of reasoning. In my case it was the other way around. I made sure I downloaded D2 but found a code snippet for D1 (I think). I'm starting to realize this is probably an issue with free examples, tutorials, etc. The code isn't posted with comments or context as how it will compile. If I ever start offering my code on the web I'm going to put in the first comment line of the source code what context it compiled and ran under. e.g. DMD v2.058/Phobos/Win32/etc. Then if some newbie slacker like us is looking at the code 2 years from now, he will have some idea of whether he should try it. And if it doesn't compile, he can say "well that example was v2.058/Win32 and this is V4.01/Linux64 that I am running." ....and not get frustrated.
[...] +1. This is a good suggestion. T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
Apr 18 2012