Would like to see ref and out required for function calls

Kevin McTaggart kevin.mctaggart at drdc-rddc.gc.ca
Wed Sep 19 07:37:52 PDT 2012


I'm amazed and very pleased at the discussion that this has 
generated.  I think it would be great if ref and out required for 
function calls in D3.  As others have mentioned, it would greatly 
assist with code readability.

On Friday, 7 September 2012 at 11:33:41 UTC, Kevin McTaggart 
wrote:
> I've been looking at migrating a reasonably large ship motion 
> library (tens of thousands of lines) from C# to D.  I've become 
> quite enthusiastic about D, and most of my problems have been 
> relatively minor (e.g., inconsistent bugs with 
> std.container.Array, would like orange serialization to give me 
> an error telling me I didn't register a class before calling 
> serialize).  I suggest that the language require ref and out 
> when calling functions, as C# requires.  This would make code 
> easier to understand, and would also eliminate the problem I 
> had when the wrong function from the following choices was 
> mistakenly called:
>
> parseLineInts(string text, int positionStart, out int j0, out 
> int j1)
>
> parseLineInts(string text, out int j0, out int j1, out int j2)
>
> I note that the second function calls another function as 
> follows:
> int positionStart = 1;
> parseLineInts(text, positionStart, j0, j1, j2);
>
> I look forward to seeing feedback from D experts.  This is the 
> only significant change that I could think of recommending for 
> the language.




More information about the Digitalmars-d mailing list