On Monday, 19 May 2014 at 09:56:38 UTC, bearophile wrote:
evilrat:
i may overlooked proposals for this case, if any please give a
link, sorry for possible duplicate topic.
This proposal was discussed two or three times in past, it
makes the D code look a little worse (beside being a breaking
change if you want require the ref at the calling point). But
it also makes D code a little less surprising.
the idea is just give a warning for ref if not explicitly stated
so. no code breakage should occur, only i little warning.
honestly i can't imagine how it makes code look worse, especially
since this is a keyword it should be really easy visually
distinctable in editors.
As refinement of this idea, some people suggested to require
"ref" at the calling point only if the reference is mutable.
good point too. though i don't know current behaviour for
immutable refs.
And what about the "out" function arguments? Don't you want to
annotate them too at the calling point?
ummm... yes i forgot that there is also "out", but isn't it
working *almost* same way as ref? with "out" we specifically asks
function to mutate our data for result. if this is real problem
maybe some other keyword should be added for both cases at once,
something like "rout" from ref and out?