How to include??
Ary Manzana
ary at esperanto.org.ar
Sat Oct 20 08:36:13 PDT 2007
Bruno Medeiros escribió:
> Ary Manzana wrote:
>> BCS wrote:
>>> import is only allowed at module scope, not in a class or function or
>>> sutch.
>>
>> IIRC import is allowed in classes. Also in structs, version, debug, etc.
>
> Apparently it's allowed in function/statements scope too, with a
> workaround:
>
> template Tpl() { import std.stdio; }
>
> void func() {
> mixin Tpl!();
>
> writefln("Foo");
> }
>
> void main() {
> //writefln("Foo"); // writefln not available
> func();
> }
>
> Seems it's only disallowed on a syntactic level.
>
Smart :-)
More information about the Digitalmars-d-learn
mailing list