opApply Vs. Ranges: What should take precedence?
Justin Johansson
no at spam.com
Fri Nov 20 16:22:35 PST 2009
Bill Baxter wrote:
> On Fri, Nov 20, 2009 at 3:36 PM, Walter Bright
> <newshound1 at digitalmars.com> wrote:
>> And here I was thinking perhaps opApply should just be dumped in favor of
>> ranges.
>>
>
> I think the opApply should take precedence.
> The only reason to define opApply is because foreach uses it.
> Ranges on the other hand are useful in other situations.
>
> --bb
Is is absolutely necessary for opApply to take a ref parameter? (I'm
asking from D1 familiarity not D2 so question might not be relevant).
My understanding is that by taking a ref parameter there is an
additional pointer dereference to get to the actual datum that is the
subject of current application. Of course the current regime does
appear to allow a foreach to modify the items in the "container" being
iterated over, though myself, I've only ever used foreach in readonly mode.
Justin Johansson
More information about the Digitalmars-d
mailing list