Re: Scope of import

2021-05-15 Thread DLearner via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:38:22 UTC, Adam D. Ruppe wrote> Just use ``` dmd -i main.d instead. It will be about 2x faster and more reliable. ``` Your suggestion worked. Thank you.

Re: Scope of import

2021-05-15 Thread Alain De Vos via Digitalmars-d-learn
In unix i give the compiler: ``` ldc2 `find . -name \*.d -print` ``` So he always takes all sourcefiles

Re: Scope of import

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:46:49 UTC, Dennis wrote: You can do `dmd -i -run main.d` Yeah but that's weird with how it handles arguments and without the compilation cache it gets really annoying to use.

Re: Scope of import

2021-05-15 Thread Dennis via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:38:22 UTC, Adam D. Ruppe wrote: * rdmd runs the program too, dmd -i just compiles. You run the program separately. You can do `dmd -i -run main.d`

Re: Scope of import

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:15:51 UTC, DLearner wrote: rdmd main.d rdmd sucks, it runs the compiler twice and get the list of imports and even then it might not see them all. Just use dmd -i main.d instead. It will be about 2x faster and more reliable. The downside differences though:

Re: Scope of import

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:15:51 UTC, DLearner wrote: On Saturday, 15 May 2021 at 07:05:00 UTC, Mike Parker wrote: That's odd. What's your command line? rdmd main.d Okay, so it's definitely a bug in rdmd. Change module A to look like this and it works properly: ```d module A;

Re: Scope of import

2021-05-15 Thread DLearner via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:19:08 UTC, Mike Parker wrote: Then it must be an issue with rdmd... rdmd build 20210311 Running under Win-10.

Re: Scope of import

2021-05-15 Thread DLearner via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:05:00 UTC, Mike Parker wrote: That's odd. What's your command line? rdmd main.d

Re: Scope of import

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:15:51 UTC, DLearner wrote: On Saturday, 15 May 2021 at 07:05:00 UTC, Mike Parker wrote: That's odd. What's your command line? rdmd main.d Then it must be an issue with rdmd. The following both work as expected, whether your the `import B;` in `main` is

Re: Scope of import

2021-05-15 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 06:55:47 UTC, DLearner wrote: 1. Code above compiles but fails on linker step with 'Error 42 Symbol Undefined'. To me, unexpected behaviour as imports arranged to pick up symbols (with minimum scope). Your error is a linker error. Imports have nothing to do with

Scope of import

2021-05-15 Thread DLearner via Digitalmars-d-learn
``` // main void main() { import A; // import B; import std.stdio; writeln("Entered main"); fnA1(); writeln("Leaving main"); } ``` ``` module A; void fnA1() { import B; import std.stdio; writeln("Entered fnA1"); fnB1(); writeln("Leaving fnA1"); } ``` ```