How to include??

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Oct 19 13:45:37 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. :-)
> 

Hum, you're right. That's quite odd, I has the distinct impression of 
trying that before (when looking how Mmrnmhrm functionality should work) 
and it not working that way. Was there maybe some DMD version that 
didn't work that way I wonder?...

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D


More information about the Digitalmars-d-learn mailing list