On 10/09/2012 21:36, Timon Gehr wrote:
On 09/09/2012 02:54 PM, Nick Treleaven wrote:
On 08/09/2012 19:17, Timon Gehr wrote:
On 09/08/2012 06:05 PM, Nick Treleaven wrote:
On 08/09/2012 14:05, Chris Nicholson-Sauls wrote:
Given:

void func (ref int[], int)

If ref/out were required at the call site, this destroys UFCS.

int[] array;
array.func(0); // error, ref not specified by caller

For UFCS, ref should be implied.

Why? UFCS means uniform function call syntax.

I meant if callsite ref was required for parameters, it should not be
required for array in 'array.func()'. It would be bizarre to require
'(ref array).func()'.


Not more bizarre as in other positions.

The brackets make it more ugly though. The reason why it is not necessary is that in general, function arguments are not implicitly modified (and some languages enforce this). But when you see foo.bar() and you don't know what bar does, you don't assume that foo won't be modified, even across many languages.

This is not necessarily a valid conclusion. Popularity does not imply
importance.

I only said it was *arguably* important, given that the parent post said
the idea failed to gain traction. Go and Rust are relatively new and
decided for the explicit callsite approach (AFAIU).


Yes, Go uses explicit pointer types.
Regarding Rust, you are wrong.

OK, I misunderstood Rust & I apologize. Thanks for providing the example code.

What is this claim based on? The use case above is probably one of the
more common ones.

How often do you use swap?


Whenever I want to swap the values of two variables. All other
functions in my current project except one that use ref either pass by
const/immutable ref, or all arguments are ref, or they are function
pointer literals that are part of a polymorphic value type where it is
obvious that the first parameter is passed by ref. The remaining
function is private and declared right between the methods that use it.

Then callsite ref might not help you at all. I think Manuel's recent post is better than anything I could write to support the idea.

Reply via email to