Array as an argument, ambiguous behaviour.
bearophile
bearophileHUGS at lycos.com
Thu Jan 30 02:54:19 PST 2014
Cooler:
> Again - stop consider current state of D implementation.
> Consider how we can make D better. I think fun3() push
> programmers to make errors.
I think functions like void fun(int[] a){} are bug prone, because
you seem to change the length of the array inside the function,
or if you perform an append you modify a new memory zone, but
such changes are invisible from the caller. Some times this is
what you want, and in some cases this is a programmer mistake
(this bug happened to me several times).
But I don't know what to change and if this situation can be
improved now. Perhaps all that's left to improve is to add tests
to a D lint that warns against this possible source of bugs.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list