Explicitly saying ref or out when invoking a function
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Tue Aug 11 12:47:15 PDT 2009
Ary Borenszweig wrote:
> In C# when you define a function that takes an out or ref parameter,
> when invoking that function you must also specify ref or out. For example:
>
> void fun(ref uint x, double y);
>
> uint a = 1;
> double b = 2;
> fun(ref a, b);
>
> What do you think?
I see what you mean, however:
-----
swap(ref a, ref b);
I think that's overly verbose for a call with very descriptive function name
to begin with.
-----
Perhaps an IDE can use formatting to show you the ref parameters.
-----
The designer of the function can always request pointers, so the caller has
to explicitly pass addresses.
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list