Has the ban on returning function nested structs been lifted?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Mar 18 13:13:35 PDT 2011
On Friday 18 March 2011 12:48:17 Andrei Alexandrescu wrote:
> On 3/18/11 1:21 PM, Jonathan M Davis wrote:
> > Yeah. Actually, Andrei has been making changes to std.range and
> > std.algorithm so that _most_ functions which return new range types work
> > this way. So, if TDPL says that it's illegal, it probably needs to be
> > changed. Either that or we need to stop switching over to doing things
> > that way. On the whole though, it strikes me as a positive change.
> >
> > - Jonathan M Davis
>
> Yah, TDPL needs changing. Auto returns + local types = just awesome.
Actually, the coolest part about it IMHO is that it highlights the fact that you
should be using auto with std.algorithm and _not_ care about the exact types of
the return types. Knowing the exact return type for those functions is generally
unnecessary and is often scary anyway (especially with the functions which
return lazy ranges like map and until). Making the functions return auto and
completely hiding the return type pretty much forces the issue. There's still
likely to be some confusion for those new to D, but it makes the proper way to
use std.algorithm more obvious. I'd hate to deal with any code which used
std.algorithm without auto. That would get ugly _fast_.
So, yeah. auto returns + local types are indeed awesome.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list