Re: Complicated Types: Prefer “alias this” Over “alias” For Easier-To-Read Error Messages
Nick Sabalausky (Abscissa)
SeeWebsiteToContactMe at semitwist.com
Mon May 21 20:29:26 UTC 2018
On 05/21/2018 01:30 PM, Paul Backus wrote:
>
> I'm not sure making `_data` private is really a good idea. For example,
> this only works if `_data` is public:
>
> import std.algorithm;
> import std.range;
> import std.stdio;
>
> struct MyType
> {
> auto _data = iota(10);
> alias _data this;
> }
>
> void main()
> {
> MyType x;
> x.each!writeln;
> }
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?
More information about the Digitalmars-d-announce
mailing list