as topic says sometimes ref has a 'little' problem now, it is
unavoidable in some cases and has some readability in code and
much more...
imagine we have a function "void getMyNumber(ref int number)"
which assigns 42 to 'number', now lets look at C# code first:
----------- C# code -------------
int someNumber = 3;
MyCoolLibraryClass.getMyNumber(ref someNumber);
------------------------------
ok, it clearly shows where our variable could be changed, now
look at same D code:
----------- D code -------------
int someNumber = 3;
getMyNumber(someNumber);
assert(someNumber == 42);
------------------------------
wait... what? what does this function? is it using our nice
variable to do some computation with it? or maybe it is assigned
something to our varible? and what if we had lot of other
function calls before this? how to know our variable stay the all
time we feed it to functions?
now this is the problem, ref arguments isn't that obvious as it
should be, it is very easy to mess up in code and spent hours to
see what's going wrong. currently i trying to add /*ref*/ comment
before passing such variables to functions. we should really
change this behaviout and add warning when passing ref args to
functions if it doesnt have ref keyword like in C#, i don't ask
to enfoce, but such little tweak would help a lot.
i may overlooked proposals for this case, if any please give a
link, sorry for possible duplicate topic.