Should out/ref parameters require the caller to specify out/ref like in C#?

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Mon May 29 01:21:51 PDT 2017


Meta wrote:

> On Sunday, 28 May 2017 at 19:10:49 UTC, ketmar wrote:
>> Meta wrote:
>>
>>> If a parameter is marked as ref then you have to assume it will be 
>>> modified by the function (unless it's const/inout/immutable). If it's 
>>> marked as out then you know it will be. If you didn't know that the 
>>> function takes its parameters by ref or out... You're should've RTFM.
>>
>> now imagine that you're reading some code:
>>
>> 	foo(a);
>>
>> vs:
>>
>> 	foo(ref a);
>>
>> which code style is easier to read without constant jumping into 
>> documentation?
>
> Is this ever actually a problem in practice?

yes. aliced has this syntax for a long time. for a reason. and i must say 
that i'm adding alot of random features to aliced, but very little of 'em 
survives.

> Anyway, having to add ref or out at the call site will greatly hamper 
> metaprogramming.

not more then "&" does. except with `auto ref` -- which is misdesigned 
feature anyway (forcing programmer to do the work compiler can do without 
any external help is not a good design; besides, compiler can do that work *better*).


More information about the Digitalmars-d mailing list