public import and bugs it causes
Nick Sabalausky
a at a.a
Fri May 14 11:26:32 PDT 2010
"bearophile" <bearophileHUGS at lycos.com> wrote in message
news:hsk3rk$1rb8$1 at digitalmars.com...
> Alex Makhotin:
>
>> Today I found a strange bug in my code which was caused by 'public
>> import' declaration from the wxD library.
>
> I can enjoy seeing public imports removed from D. They are a failed idea.
>
1. The problem he had had nothing to do with public imports. Any of the
modules he was importing could just as easily had a global var named "name"
and would have caused the same problem.
2. Public imports are very useful. I never want to see them go. Examples:
-------------------------------------
// Vastly superior alternative to "import foolib.*;" which D
// (fortunately) doesn't even have anyway.
module foolib.all;
public import foolib.blah1;
public import foolib.blah2;
// Ignore foolib.privateFooLibModule;
public import foolib.blah3;
//etc...
-------------------------------------
module aToolIAmWritingThatMakesItEasyToUseDForScriptStyleProgramming;
// Obviously only intended for short apps, not big projects.
public import superUsefulStdModule1;
public import superUsefulStdModule2;
// A few workarounds for symbol conflicts here
-------------------------------------
module foolib.osWrapper;
version(Windows)
public import foolib.osWrapper_win;
else
public import foolib.osWrapper_unix;
-------------------------------------
More information about the Digitalmars-d
mailing list