imports in a Separate File?

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 11 15:39:18 UTC 2018


On 12/11/18 10:27 AM, Ron Tarrant wrote:
> I ran across a code example 
> (https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/TestWindow/TestWindow.d) 
> in which the first ~120 lines are mostly import statements.
> 
> And it got me wondering...
> 
> I tried to off-load a bunch of imports into a pseudo-header file — 
> importedStuff.d — and then in the actual code file I just did:
> 
> import importedStuff;
> 
> but found myself swimming in undefined identifier errors.
> 
> Is there a way to do this so I wouldn't have to scroll 120 lines into a 
> file before finding code? Or does this mean I still haven't caught onto 
> what I was told the last time I was on this forum?
> 
> (And here's a grammar question, just for the heck of it: Why isn't forum 
> spelled with an 'n,' like column?)
> 

Use public imports in your header file. This will pretend that the 
symbols imported reside in the module itself.

i.e. inside importedStuff.d:

public {
    // 120 import statements
}

-Steve


More information about the Digitalmars-d-learn mailing list