On Thu, Jul 17, 2014 at 10:33:26PM -0700, Walter Bright via Digitalmars-d wrote: > On 7/17/2014 3:16 PM, Dicebot wrote: > >On Thursday, 17 July 2014 at 22:06:01 UTC, Brad Anderson wrote: > >>I agreed with this for awhile but following the conversation here > >><https://github.com/D-Programming-Language/phobos/pull/2149> I'm > >>more inclined to think we should be adding lazy versions of > >>functions where possible rather than versions with OutputRange > >>parameters. It's more flexible that way and can result in even fewer > >>allocations than even OutputRange parameters would have (i.e. you > >>can have chains of lazy operations and only allocate on the final > >>step, or not at all in some cases). > >> > >>Laziness isn't appropriate or possible everywhere but it's much > >>easier to go from lazy to eager than the other way around. > >> > >>>[...] > > > >This is not comparable. Lazy input range based solutions do not make > >it possible to change allocation strategy, they simply defer the > >allocation point. Ideally both are needed. > > They move the allocation point to the top level, rather than the > bottom or intermediate level.
Deferring the allocation point to the top level has the advantage of letting high-level user code decide what the allocation strategy should be, rather than percolating that decision down the call graph to every low-level function. Of course, it's not always possible to defer this, such as if you need to tell a container which allocator to use. But IMO this should be pushed up to higher-level code whenever possible. T -- Why can't you just be a nonconformist like everyone else? -- YHL