How to include??

Bill Baxter dnewsgroup at billbaxter.com
Thu Oct 18 18:45:27 PDT 2007


Ary Manzana wrote:
> This compiles, runs, and outputs "hola" as expected:
> 
> ---
> class X {
>     import std.stdio;
>     void foo() {
>         writefln("hola");
>     }
> }
> 
> void main() {
>     (new X()).foo();
> }
> ---
> 
> Even more, if you move the foo function outside X, it doesn't compile 
> because it can't find "writefln". If I remember correctly from what I've 
> seen in DMD's code, the import loads the imported symbols into the 
> symbol table of the current scope (X, in this case). So... it works. :-)

Hey, then maybe that's a good workaround for no imports in unittests.
Just make a big Test class inside unittest{...} that does all the work.

--bb


More information about the Digitalmars-d-learn mailing list