Why import statements are not allowed in function bodies (or any block of code)?

Russell Lewis webmaster at villagersonline.com
Fri Feb 1 08:38:44 PST 2008


David Wilson wrote:
> When I started using D I thought this was pretty ugly too, but in
> retrospect I can't see any problem at all any more. Specifically,
> importing a module merely brings its symbols into view, it does *not*
> result in some magical linking of code from that module or anything
> else.

Magical linking, no.  But it does allow you to access symbols in modules 
which you are going to link to anyhow but which normally would not be 
referenced in your code.  std.stdio.writeln() is a classic example.



More information about the Digitalmars-d mailing list