Explicit implicit conversions

Paul Backus snarwin at gmail.com
Fri Feb 7 02:52:20 UTC 2025


On Thursday, 6 February 2025 at 14:45:43 UTC, Quirin Schroll 
wrote:
> The deal is that something that’s that trivial shouldn’t 
> require a workaround, not even an easy one. It would have to be 
> in object.d to be easily used, otherwise I’d rather two-line it 
> with a local variable than two-line it with an `import` 
> statement.
>
> Really, there’s almost no benefit anymore if you have to import:
> ```d
> import std.conv : implicitCast; // meh
> f(x.implicitCast!R);
> ```

Where is all this whining about imports when it comes to other 
simple library functions, like `max` or `abs`? It seems to me 
like "having to import" is something that people love to complain 
about in DIP threads, but have no trouble with when it comes to 
actually writing code.

In any case, the primary goal here (and with the analogous 
proposal for reinterpreting casts) is to help D programmers write 
correct, readable, and maintainable code, not to minimize the 
number of lines they have to type.


More information about the dip.ideas mailing list