import all except specified symbols: eg import std.stdio:!writeln,write;

Artur Skawina art.08.09 at gmail.com
Mon Sep 10 03:52:15 PDT 2012


On 09/10/12 01:33, timotheecour wrote:
> I'd like to have something like:
> ---
> import std.stdio:!writeln,write;
> ---
> which would import all symbols from std.stdio except the ones listed (writeln,write).
> 
> Use case:
> The reason is to avoid writing verbose code (specifying all symbols to import except those 2), example when writing a module (eg overrides.stdio) which overrides just those 2 symbols (eg for logging to a file each call to write,writeln) but keeps the rest intact.
> 
> Is there a way or can that be implemented?

   import std.stdio;

   float writeln(double a) { return a*a; }

   void main() {
      writeln(3.14);
      writeln("original no longer accesible");
   }

artur


More information about the Digitalmars-d-learn mailing list