On Monday, 4 January 2021 at 13:47:17 UTC, Ola Fosheim Grøstad wrote:
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/nxrfrizqdmhzhivxp...@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.

I have a longer reply I'm trying to write, but just to make sure I'm on the right track:

    template Foo(T) {
        alias Foo = T;
    }

    template Q(A : Foo!T, T) {
        pragma(msg, A.stringof, " ", T.stringof);
    }

    alias X = Q!(Foo!int);

in your opinion, this should compile and msg `int int`, yes?

I'm trying to make a really concise example without using IFTI.

Reply via email to