www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - The first example in the Learning D book, wont compile

reply Ali <fakeemail example.com> writes:
Hi

The first example in the Learning D book

import core.thread;
import std.stdio;

void main() {
     import std.range: iota, range;
     write("Greeting in, ");
     foreach(num; iota(1, 4).range) {
         writef("%s...", num);
         stdout.flush();
         Thread.sleep(1.seconds);
     }
     writeln();
     writeln("Hello, World");
}


wont compile and give this error

hello.d(5): Error: module `std.range` import range not found

this should be an easy issue to fix, except that googling this 
error doesnt return anything useful
Mar 25 2018
next sibling parent reply Ali <fakeemail example.com> writes:
On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote:
 Hi

 The first example in the Learning D book

 import core.thread;
 import std.stdio;

 void main() {
     import std.range: iota, range;
     write("Greeting in, ");
     foreach(num; iota(1, 4).range) {
         writef("%s...", num);
         stdout.flush();
         Thread.sleep(1.seconds);
     }
     writeln();
     writeln("Hello, World");
 }


 wont compile and give this error

 hello.d(5): Error: module `std.range` import range not found

 this should be an easy issue to fix, except that googling this 
 error doesnt return anything useful
I now see my typo, should be retro, not range
Mar 25 2018
parent reply Ali <fakeemail example.com> writes:
On Sunday, 25 March 2018 at 20:52:29 UTC, Ali wrote:
 On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote:
 I now see my typo, should be retro, not range
We need better IDEs, this would have been easily highlighted by a good ide
Mar 25 2018
parent Graham Fawcett <fawcett uwindsor.ca> writes:
On Sunday, 25 March 2018 at 21:02:26 UTC, Ali wrote:
 On Sunday, 25 March 2018 at 20:52:29 UTC, Ali wrote:
 On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote:
 I now see my typo, should be retro, not range
We need better IDEs, this would have been easily highlighted by a good ide
I pasted your code into Spacemacs, and it highlighted the error immediately. What editor are you using? Graham
Mar 26 2018
prev sibling parent Seb <seb wilzba.ch> writes:
On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote:
 Hi

 The first example in the Learning D book

 import core.thread;
 import std.stdio;

 void main() {
     import std.range: iota, range;
     write("Greeting in, ");
     foreach(num; iota(1, 4).range) {
         writef("%s...", num);
         stdout.flush();
         Thread.sleep(1.seconds);
     }
     writeln();
     writeln("Hello, World");
 }


 wont compile and give this error

 hello.d(5): Error: module `std.range` import range not found

 this should be an easy issue to fix, except that googling this 
 error doesnt return anything useful
The problem is `std.range : range` - range is not a symbol of std.range: --- import core.thread; import std.stdio; void main() { import std.range: iota; write("Greeting in, "); foreach(num; iota(1, 4)) { writef("%s...", num); stdout.flush(); Thread.sleep(1.seconds); } writeln(); writeln("Hello, World"); } --- https://run.dlang.io/is/p9rFrS
Mar 25 2018