www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Nested imports - y/n

reply adnan338 <relay.public.adnan outlook.com> writes:
Hello, has the idea of nested imports been explored yet?
For example if you have:

import gtk.Application : Application;
import gtk.ApplicationWindow : GAW = ApplicationWindow;
import gtk.Nested.This: Symbol;
import gtk.Nested.That;
import gtk.Entry;


With nested imports you would just write something like:

import gtk(
     Application: Application,
     ApplicationWindow: GAW = ApplicationWindow,
     Nested(
         This : Symbol,
         That
     ),
     Entry,
);

It would reduce some typing.
Jun 21 2020
parent Eugene Wissner <belka caraus.de> writes:
On Monday, 22 June 2020 at 03:54:56 UTC, adnan338 wrote:
 Hello, has the idea of nested imports been explored yet?
 For example if you have:

 import gtk.Application : Application;
 import gtk.ApplicationWindow : GAW = ApplicationWindow;
 import gtk.Nested.This: Symbol;
 import gtk.Nested.That;
 import gtk.Entry;


 With nested imports you would just write something like:

 import gtk(
     Application: Application,
     ApplicationWindow: GAW = ApplicationWindow,
     Nested(
         This : Symbol,
         That
     ),
     Entry,
 );

 It would reduce some typing.
Define a module with imports and aliases you need and import this module instead of the direct library imports.
Jun 22 2020