Feedback on Átila's Vision for D

Paul Backus snarwin at
Wed Oct 16 00:22:08 UTC 2019

On Tuesday, 15 October 2019 at 23:52:52 UTC, jmh530 wrote:
> DIP1023 addresses creating the alias
> alias PackedUpperTriangularMatrix(T) = 
> Slice!(StairsIterator!(T*, "-"));
> and then enabling the ability to write
> auto foo(T)(PackedUpperTriangularMatrix!T m) { }
> without the current error.
> Nothing would be stopping you from writing the equivalent of
> auto foo(T)(Slice!T m) { }
> as well.
> That last version of foo taking a slice would be the equivalent 
> of your input range version, while the second one would be the 
> equivalent of random access range version. Unlike above, these 
> examples are no longer using the template constraints. It is 
> treating the aliases as types so the normal function 
> overloading rules should apply.

This does not solve the ambiguity issue. If I write the 
equivalent code with the aliases expanded by hand, I get a 
compile-time error:

import std.stdio;

struct Outer(T) {}
struct Inner(T) {}

void fun(T)(Outer!(Inner!T) arg) { writeln("Outer!(Inner!T)"); }
void fun(T)(Outer!T arg) { writeln("Outer!T"); }

void main() {
     Outer!(Inner!int) x;
     fun(x); // Error: called with argument types 
[...] matches both:

More information about the Digitalmars-d mailing list