On Wednesday, 29 January 2014 at 13:15:30 UTC, Cooler wrote:
On Wednesday, 29 January 2014 at 12:40:00 UTC, Tobias Pankrath
wrote:
On Wednesday, 29 January 2014 at 11:46:23 UTC, Cooler wrote:
Thank you for detailed explanation. But the question is - "Is
that correct that language allows ambiguous behavior?"
Where is it ambiguous?
Ambiguity is here...
When I call fun1() or fun2() I know the behavior directly from
function signature (read the comments in my first post). For
fun3() case the caller side don't know the behavior directly
from function signature. To know what will happen with array
"a", the caller must see to fun3() body.
Ambiguity is - in first and second cases the caller knows what
happens with "a", but in third case the caller does not know
what happens with "a".
'in' is a shorthard for 'const scope'.
'const' means that the callee cannot change the passed in
parameter in any way, including anything available through that
type (for example x[0])
'scope' means it cannot leave the scope of the callee - that it
cannot be stored away anywhere.
'ref' means that the parameter is passed by reference, and thus
might be reassigned or changed in any way.
No parameters means that it's mutable, but the reference cannot
change.
I don't see any ambiguities here.