www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Renamed but non-selective import?

reply cc <cc nevernet.com> writes:
Is it possible to import all symbols of a module, while renaming 
just one of them?  It seems like doing an import with renaming 
automatically makes it selective.
In the example below, I'd prefer not to have to use the fully 
qualified name for mymodule.MSG every time e.g.:

import core.sys.windows.windows;
import mymodule; // contains a struct named MSG
Error: `core.sys.windows.winuser.MSG` ... conflicts with 
`mymodule.MSG`

vs

import core.sys.windows.windows : winMSG = MSG; // this leaves 
out other symbols
Error: undefined identifier `HWND`
Error: undefined identifier `LPCSTR`
Jan 12 2021
parent reply ag0aep6g <anonymous example.com> writes:
On 12.01.21 21:09, cc wrote:
 import core.sys.windows.windows;
 import mymodule; // contains a struct named MSG
 Error: `core.sys.windows.winuser.MSG` ... conflicts with `mymodule.MSG`
 
 vs
 
 import core.sys.windows.windows : winMSG = MSG; // this leaves out other 
 symbols
 Error: undefined identifier `HWND`
 Error: undefined identifier `LPCSTR`
import core.sys.windows.windows; import mymodule; alias MSG = mymodule.MSG; alias winMSG = core.sys.windows.windows.MSG;
Jan 12 2021
parent cc <cc nevernet.com> writes:
On Tuesday, 12 January 2021 at 20:19:20 UTC, ag0aep6g wrote:
 On 12.01.21 21:09, cc wrote:
 import core.sys.windows.windows;
 import mymodule; // contains a struct named MSG
 Error: `core.sys.windows.winuser.MSG` ... conflicts with 
 `mymodule.MSG`
 
 vs
 
 import core.sys.windows.windows : winMSG = MSG; // this leaves 
 out other symbols
 Error: undefined identifier `HWND`
 Error: undefined identifier `LPCSTR`
import core.sys.windows.windows; import mymodule; alias MSG = mymodule.MSG; alias winMSG = core.sys.windows.windows.MSG;
Ahh simple enough, thanks.
Jan 12 2021