Passing dynamic arrays
Jesse Phillips
jessekphillips+D at gmail.com
Tue Nov 9 18:09:57 PST 2010
Jens Mueller Wrote:
> I see your point. You argue that the behavior is consistent. My point is
> that this consistency can lead to bugs. I may forget the ref. But I'll
> keep in mind to never forget the ref if it is needed.
>
> Jens
Well, in the case of classes, I don't think it would be very common.
For arrays it can be nice since you can assign back a slice of the array that you want to work with.
void main(string args) {
args = args[1..$];
}
Otherwise I suggest you start labeling all parameters with in. Then you are prevented from modifying the reference, and can decide if it should be a ref parameter. Who knows, maybe you'll find a reason to leave it off.
More information about the Digitalmars-d
mailing list