foreach/opApply
Christopher Wright
dhasenan at gmail.com
Thu Mar 19 15:45:43 PDT 2009
Steve Teale wrote:
> The class need not contain an aggregate. The values iterated can be calculated in opApply from other class members, though there should be a corresponding class member because of the ref in dg.
It could correspond to a local variable instead.
However, I'm curious about this: why is it that opApply must take a
delegate with ref parameters? This doesn't make sense in many
situations. I'm calculating values on the fly, and I can't go back if
you decrement the index; the data I am passing is immutable (or at least
in the text segment of the binary, which is protected as readonly and
will segfault if you try writing to it). But I still need to pass by
reference.
So, why? It didn't always work like that.
More information about the Digitalmars-d
mailing list