Array as an argument, ambiguous behaviour.

Tobias Pankrath tobias at pankrath.net
Wed Jan 29 09:58:03 PST 2014


On Wednesday, 29 January 2014 at 16:26:05 UTC, Cooler wrote:
> Where argument has the same length? After function call, or 
> inside function? I don't understand what my intention should be 
> to push me to use fun3()?

Where argument has the same length? After function call, or
inside function? I don't understand what my intention should be
to push me to use fun3()?

int[] a = [1,2,3]; // length == 3
fun3(a);
assert(a.length == 3); // holds.

If you have fun1 and fun2 you might have no use case for fun3. 
That is however no reason to disallow fun3, especially since 
there are situations where you don't won't to have fun2.

Keep in mind, that I'm only arguing against a ban of fun3 and the 
notion that it's behaviour is more unpredictable then fun2 
although it offers stronger guarantees.


More information about the Digitalmars-d-learn mailing list