Explicitly saying ref or out when invoking a function

Bill Baxter wbaxter at gmail.com
Tue Aug 11 13:15:18 PDT 2009


On Tue, Aug 11, 2009 at 1:05 PM, Nick Sabalausky<a at a.a> wrote:
> "Ary Borenszweig" <ary at esperanto.org.ar> wrote in message
> news:h5s3e9$2kml$1 at digitalmars.com...
>> 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);
>>
>> When I first started using C# it really annoyed me that I had to put that
>> keyword there just to get my program compiled. "I know what I'm doing", I
>> thought. But later, when reading the code, I found it very helpful to know
>> that my "a" could be changed when invoking "fun". As always, code is read
>> much more times than written, and I think this little tips help better
>> understand the code.
>>
>> What do you think?
>
> That's something I've always liked about C# and always wanted in D.
> Although, what some people have said about just coloring it in an editor is
> not a bad point (althogh it seems like we may be starting to run out of
> colors...).

No problem,  we can resurrect <BLINK>!

--bb



More information about the Digitalmars-d mailing list