small idea

bearophile bearophileHUGS at lycos.com
Wed Jan 9 07:10:46 PST 2013


eles:

> void make_a_equal_to_b(??a,!!b); //I give you "b", give me "a"

A saner syntax is just to use the same in/out/inout keywords at 
the call point, This is essentially what C# does (with one 
exception for COM):

make_a_equal_to_b(ref a, in b)

This feature was discussed several times in past for D. The 
advantage is more readability for the code and less surprises. 
The disadvantages are more typing, some code breakage of D2 code 
(because even if at the beginning it's a warning, and later a 
deprecation, you will eventually need to enforce it with an 
error).

One more small D-specific problem is what to do if the first 
argument is a ref and you want to use UCFS.

In the end it's one of those features that are borderline, they 
have both advantages and disadvantages. I generally like 
languages that are clear and avoid surprises.

Bye,
bearophile


More information about the Digitalmars-d mailing list