Would like to see ref and out required for function calls

Kevin McTaggart kevin.mctaggart at drdc-rddc.gc.ca
Fri Sep 7 04:34:02 PDT 2012


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