Workaround for DIP 1005

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 3 11:16:47 PST 2017


On 2/3/17 2:14 PM, Andrei Alexandrescu wrote:
> On 2/3/17 10:41 AM, Daniel N wrote:
>> On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes Scherkl
>> wrote:
>>> DIP 1005 provides new syntax to make it possible to avoid global
>>> imports.
>>> Any thoughts?
>>
>> I like it!
>>
>> template imp(string mod)
>> {
>>   mixin("import imp = " ~ mod ~ ";");
>> }
>>
>> auto fun_time(imp!"std.datetime".SysTime tm)
>> {
>>   return tm;
>> }
>>
>> void main()
>> {
>>   import std.stdio;
>>   import std.datetime;
>>
>>   fun_time(Clock.currTime()).writeln;
>> }
>
> Wow. This is... brilliant. Thanks for the great idea. I ran a few tests
> and it seems to be doing out of the box most of what we want with
> DIP1005 with no language change at all.
>
> Congratulations!

I should also extend thanks to Dominik, who provided the initial idea 
and the inspiration for this one. -- Andrei



More information about the Digitalmars-d mailing list