Why can't we put import in functions.
Brad Roberts
braddr at puremagic.com
Tue Oct 16 00:49:43 PDT 2007
Bruce Adams wrote:
> Robert Fraser Wrote:
>
>> Yang Bo Wrote:
>>
>>> We can put "using namesapce" in any place in C++. Why not do the same
>>> way in D?
>> mixin(import(FILENAME));
>>
>> You may need a compile-time function to strip the module declaration and be wary of forward references.
>
> Its practices like this that will result it someone writing D++ or E or
> switching to something else entirely. Ugly ugly ugly. Do not promote.
>
> Bruce.
Aside from the overt ugliness of the suggestion, it's also significantly
different.
C++'s "using namespace" and D's 'import' convey symbol visibility. D's
mixin(import(filename)) is direct inclusion of code, implementation and
all. That mixin syntax is the equivalent of C/C++'s #include
preprocessor token.
Later,
Brad
More information about the Digitalmars-d
mailing list