Calling functions from other files/modules

2016-01-06 Thread Namal via Digitalmars-d-learn
Hello, finally I want to learn how to do it right and I tried to understand it from here https://en.wikibooks.org/wiki/D_(The_Programming_Language)/d2/Modules But I have a few questions. Do I have always to include std.stdio in every file like in the example or is it enough just to import a

Re: Calling functions from other files/modules

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 22:06:32 UTC, Namal wrote: Do I have always to include std.stdio in every file like in the example or is it enough just to import a module which has this already included? In every file that you use it, yes. Module imports are private to the module (well, unles

Re: Calling functions from other files/modules

2016-01-06 Thread Namal via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 22:15:43 UTC, Adam D. Ruppe wrote: You can import it as long as you define it! I just tried to import one module with a main into another, but I get this: Error: only one main allowed

Re: Calling functions from other files/modules

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote: I just tried to import one module with a main into another, but I get this: You can't have two mains, but you can import a module with main from another module without one.

Re: Calling functions from other files/modules

2016-01-06 Thread Namal via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:06:38 UTC, Adam D. Ruppe wrote: On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote: I just tried to import one module with a main into another, but I get this: You can't have two mains, but you can import a module with main from another module without

Re: Calling functions from other files/modules

2016-01-06 Thread tcak via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:12:27 UTC, Namal wrote: On Wednesday, 6 January 2016 at 23:06:38 UTC, Adam D. Ruppe wrote: On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote: I just tried to import one module with a main into another, but I get this: You can't have two mains, but yo