Alias woes

SealabJaster sealabjaster at gmail.com
Sat Dec 19 07:41:09 UTC 2020


On Thursday, 17 December 2020 at 22:06:00 UTC, SealabJaster wrote:
> ...

Well, at least I understand why the context pointer exists now.

If you were to add a `pragma(msg, __FUNCTION__)` into either of 
the templated functions, you'd get the following output.

```
example.C.doShizz!(a).doShizz
example.C.staticShizz!(a).staticShizz
```

Where `example` is likely the name of the module in Godbolt.

But then there's the `.C.` part, which is the parent type for the 
alias being passed into the templated functions.

So essentially, the compiler is rewriting `doShizz!(C.a)` as 
something like?:

```
struct C
{
     int a;

     template doShizz(alias T = a)
     {
         void doShizz(ref string a){...}
     }
}
```

Weird, and annoying. Especially since the compiler still allows 
it to be a function instead of a delegate.


More information about the Digitalmars-d-learn mailing list