Complicated Types: Prefer “alias this” Over “alias” For Easier-To-Read Error Messages

Paul Backus snarwin at gmail.com
Tue May 22 14:32:00 UTC 2018


On Monday, 21 May 2018 at 20:29:26 UTC, Nick Sabalausky 
(Abscissa) wrote:
> Ouch, and the error message isn't very helpful either. I wonder 
> what causes this to fail though, and whether it might simply be 
> a compiler bug?

I'm pretty sure it's intended behavior. Templates are 
instantiated in the same module they're declared in [1], so since 
`_data` isn't visible in `std.algorithm`, `each` can't see it.

It's arguable that there ought to be an exception for `alias 
this`, but I expect that kind of change would require a DIP.

[1]: https://dlang.org/spec/template.html#instantiation_scope


More information about the Digitalmars-d-announce mailing list