Thread overview | |||||
---|---|---|---|---|---|
|
December 11, 2018 imports in a Separate File? | ||||
---|---|---|---|---|
| ||||
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?) |
December 11, 2018 Re: imports in a Separate File? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | 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
|
December 11, 2018 Re: imports in a Separate File? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 11 December 2018 at 15:39:18 UTC, Steven Schveighoffer wrote:
> 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
Thanks, Steve. Works like a charm... but you knew that.
|
Copyright © 1999-2021 by the D Language Foundation