Printing shortest decimal form of floating point number with Mir

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Jan 4 13:47:17 UTC 2021


On Monday, 4 January 2021 at 12:35:12 UTC, John Colvin wrote:
> What's the simplest example that doesn't work and is that 
> simple example just indirection through an alias or is it 
> actually indirection through a template that *when 
> instantiated* turns out to be just an alias?

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());
   }


I created a thread for it:

https://forum.dlang.org/post/nxrfrizqdmhzhivxptsb@forum.dlang.org


> I have a suspicion that what you're asking for here is the 
> type-inference to have x-ray vision in to uninstantiated 
> templates that works for a few simple cases. Am I wrong?

No, just substitute: "Bar!int" with "Foo!int".


> To be clear, a really useful special case can be really useful 
> and worthwhile, but I'm not convinced this is the principled 
> "type system bug" you are saying it is.

Why are you not convinced?

An alias is a short hand. If it is possible to discriminate by 
the alias and the actual object then that it a semantic problem.




More information about the Digitalmars-d-announce mailing list