proposal: improved import declaration

Chris Nicholson-Sauls ibisbasenji at gmail.com
Wed May 30 06:39:28 PDT 2007


Something like this:

macro myImport (pkg, mods...) {
   foreach (m; mods) {
     import pkg.m ;
   }
}

myImport(tango.io, Console, Conduit, FilePath, FileSystem, Stdout);

And seeing as rebuild is based around the compiler's own frontend, where such macros are 
defined and expanded, I imagine it should adapt to them quite readily.  Other build 
utilities, on the other hand, might have some issue.  (Maybe it really is time to provide 
at least simple support for this in the compiler...)

-- Chris Nicholson-Sauls


eao197 wrote:
> On Wed, 30 May 2007 16:08:40 +0400, davidl <davidl at 126.com> wrote:
> 
>> wait till macro is available
>>
> 
> I'm in doubt that this will be possible to do by a macro.
> 
> And I don't think it's a good idea to modify behaviour of 'import 
> declaration' by a macro because it can make life too difficult to 
> D-oriented build tools (like rebuild).
> 
>>> The proposal is to allow writing:
>>>
>>> import <module-root>.{<name>[,<name>...]};
>>>
>>> For example, instead of:
>>>
>>> import tango.io.Console;
>>> import tango.io.Conduit;
>>> import tango.io.FilePath;
>>> import tango.io.FileSystem;
>>> import tango.io.Stdout;
>>>
>>> simply write:
>>>
>>> import tango.io.{Console, Conduit, FilePath, FileSystem, Stdout};
>>>
> 
> 
> 
> --Regards,
> Yauheni Akhotnikau



More information about the Digitalmars-d mailing list