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

timotheecour via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 16 20:09:14 PST 2017


On Wednesday, 15 February 2017 at 20:21:45 UTC, Nick Treleaven 
wrote:
> On Wednesday, 15 February 2017 at 20:09:46 UTC, Timothee Cour 
> wrote:
>> This thread completely diverged from the original post, which 
>> was propsing `::` instead of `from!`:
>>
>> ```
>> 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)
>> {...}
>> ```
>>
>> I see it as a clear improvment in readability (see original 
>> post for details along with shortcomings of `from!` approach )
>
> I really think allowing `with (module_!"std.foo")` before 
> declarations is a better solution from a DRY perspective, plus 
> it works for UFCS. This is a more general change that has other 
> benefits that apply to any static aggregate e.g. enum names - 
> `with(Enum)`, not just imports.

both are useful:

* std.stdio::File is nice for 1-off symbols only used 1 or a few 
times; simple syntax and doesn't add indentation / nesting

* with(module_!"std.foo") is useful for scoping imports to cover 
several declarations and being DRY; at the expense of adding 
indentation/nesting and less nice syntax



More information about the Digitalmars-d mailing list