On Saturday, 8 September 2012 at 17:20:21 UTC, F i L wrote:
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.

+1. The fact that a value type is modified should be information the programmer can see at a glance.




+1 here too. Coming from C# this is exactly what i was missing
from D too.

It's not only that the information that a value type is modified
should be visible to the programmer at a glance who had
originally written the code but also to other team members who
just want to do a quick read over code someone else has written
or to the people who do code review.

 From my personal experience within commercial software
development code is much more often read than written. And most
of the time it will be read by a larger amount of people one can
initially think of.

But i have to admit, that it might be too late for changes in D2
regarding this just because it would break too much existing code
(and at the moment code still breaks too often).



Andrei Alexandrescu wrote:
Actually the darndest thing is that C# has retired the syntax in 5.0 (it used to be required up until 4.0). Apparently users complained it was too unsightly.


I have never heard anyone complaining about this syntax nor have
i read of anyone complaining about this online in newsgroups or
such. From my colleagues and my circle of acquaintances only
former C++ programmers were initially complaining but they were
soon adopting this syntax and at the end they had to admit that
these additional syntax annotations at the call site make sense.

I think ref/out is like the now "forced" "override" keyword for
overridden methods - it just helps to avoid mistakes and makes
things a little bit safer.

Citation? I'm using C# 5.0 with Visual Studios 2012 on Windows 8 right now and ref/out are still required at the call sight of functions.

I have Visual Studio 2012 RC and can confirm, that ref and out
are still required even with C# 5.0 (but maybe there is some
compiler switch to disable this ??)

Reply via email to