On Wed, Aug 5, 2009 at 7:00 PM, Michel Fortin<[email protected]> wrote:
> Also, with implicit casts we wouldn't even need to bother about having a
> different names for lazy and non-lazy results, we could just do:
>
> string[] parts = str.split();
>
> and it would implicitly convert the lazy range to an array. Can this be done
> with alias this? Would need to test.
>
> struct Range(T)
> {
> T[] toArray();
> alias toArray this;
>
> ... other range things here...
> }
Sadly it doesn't work. I was hopeful when I found this works:
struct X { int x; alias x this; }
auto x = X(5);
int y = x; // works!
but if you alias a method that returns int to 'this', that line fails.