Printing shortest decimal form of floating point number with Mir

ag0aep6g anonymous at example.com
Mon Jan 4 14:11:28 UTC 2021


On 04.01.21 14:47, Ola Fosheim Grøstad wrote:
> Indirection through a parametric alias. This is the simplest I have come up with so far:
> 
> 
>   struct Foo(T) {}
> 
>   alias Bar(T) = Foo!T;
> 
>   void f(T)(Bar!T x) {}
> 
>   void main() {
>     f(Bar!int());
>   } 

On 04.01.21 14:54, Ola Fosheim Grøstad wrote:
> Typo: "discriminate between". An alias should be indistinguishable from 
> the object, you are only naming something. You should be able to use 
> whatever names you fancy without that having semantic implications, 
> that's the core PL design principle.

`Bar!int` is an alias. It's indistinguishable from `Foo!int`. The code 
fails in the same manner when you replace "Bar!int" with "Foo!int".

`Bar!T` is not yet an alias. You're asking the compiler to find a `T` so 
that `Bar!T` becomes an alias to `Foo!int`. The compiler doesn't know 
how to do that.

Issue 1807 is well worth fixing/implementing. But it's not a case of DMD 
making a difference between an alias and its source.


More information about the Digitalmars-d-announce mailing list