syntax sugar: std.path::buildPath instead of from!"std.path".buildPath

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 14 06:21:45 PST 2017


On Tuesday, 14 February 2017 at 09:55:51 UTC, Jacob Carlborg 
wrote:
> On 2017-02-14 04:49, Timothee Cour via Digitalmars-d wrote:
>> What about allowing syntax sugar as an alternative to relying 
>> on the new
>> `from/Module` inline import idiom:
>>
>> ```
>> void fun(T)(std.stdio::File input, T value) if
>> (std.traits::isIntegral!T) {...}
>> ```
>>
>> instead of:
>>
>> ```
>> void fun(T)(Module!"std.stdio".File input, T value) if
>> (Module!"std.traits".isIntegral!T) {...}
>> ```
>>
>> Rationale:
>>
>> * this reads much better (less noise); same as `=>` syntax for 
>> lambdas
>>
>> * this is expected to be a very common pattern, so might as 
>> well make it
>> as simple as possible
>
> Why? It looks awful. The signatures we already have in Phobos 
> is quite ridiculous, this will not improve. Isn't this and the 
> whole idea of DIP 1005 just a workaround for the compiler not 
> lazily analyzing the symbols.

This is what I had thought as well when Andrei first posted 
DIP1005, but he said that his main goal is actually making it so 
a declaration can carry all of its imports with it in a 
self-contained unit. When you look at it that way it makes a bit 
more sense as to why we might want constructs such as introduced 
by DIP1005 or this self-important lookup idiom.


More information about the Digitalmars-d mailing list