Call site 'ref'

Jonathan M Davis jmdavisProg at gmx.com
Sun Jan 15 16:04:28 PST 2012


On Sunday, January 15, 2012 14:36:53 Alex Rønne Petersen wrote:
> Thoughts?

This was discussed before, and I'm still completely against it. It _only_ has 
value IMHO if it's required, and even then, I don't like the idea.

If it's _not_ required, then you don't know _still_ don't know whether a 
function takes a ref or not. The lack of ref at the call site means _nothing_. 
Does

func(var);

alter var? You can't know. If it's

func(ref var);

then yes, you _do_ know that it's being altered. But this just gives you a 
false sense of security. You _still_ need to check _every_ function call which 
isn't marked with ref whether it takes its arguments by ref or not. If it were 
required, then you would know that

func(var);

doesn't take var by ref and that

func(ref var);

_does_ take var by ref. So, in that case, it's _not_ a false sense of 
security. It _actually_ guarantees something. So, it _does_ have some value in 
that case. But as long as it's optional, it's worse than not having it IMHO.

Now, personally, I don't like it regardless. It's makes function calls that 
much noisier at minimal benefit. Yes, upon occasion, I screw up and don't 
realize that a function takes an argument by ref, but that's something that I 
_should_ know. It has a definite effect on what the function does, and I should 
be aware of it.

So, I'm completely against this feature.

- Jonathan M Davis


More information about the Digitalmars-d mailing list