Inline imports redivivus

Paul Backus snarwin at gmail.com
Sun Aug 1 16:41:46 UTC 2021


On Sunday, 1 August 2021 at 16:03:05 UTC, Daniel N wrote:
>
> It looks reasonable when it appears as a simple statement, but 
> as soon as it's in an expression... it doesn't compose as well.
>
> it will result in ubiquitous double parens.
> if ((import std.datetime).SysTime > deadline)
> -> **
>
> Compare with one of the other competing suggestions
> if (module(std.datetime).SysTime > deadline)
>
> The design of D helped alot to cut down the amount of parens... 
> if you are not convinced, consider how much UFCS and single 
> argument templates helped human readability.

Actually, both examples have the same number of parentheses. :) 
But I take your point—the first version forces you to look ahead 
to figure out what the second opening paren is for, whereas in 
the second version you have the `module` keyword telling you in 
advance what to expect.


More information about the Digitalmars-d mailing list