Does D have too many features?

deadalnix deadalnix at gmail.com
Mon Apr 30 05:12:44 PDT 2012


Le 30/04/2012 04:34, H. S. Teoh a écrit :
> On Sun, Apr 29, 2012 at 11:18:12PM +0200, deadalnix wrote:
> [...]
>> C don't have out parameters as D have. C have pointer to do kind of
>> out parameters, and D have pointers too, this is a non issue.
>
> I argue that using 'out' vs. a pointer is a good thing, because it
> clarifies intent. When you see a pointer, it's far from clear whether
> it's an input parameter, an output parameter, or both.
>
> More and more, I'm leaning towards the opinion that all code should
> reveal intent, preferably in a language-supported way. Unclear intent is
> what leads to subtle bugs caused by people calling functions with wrong
> assumptions. (You'd think this should be a non-problem with programmers,
> who are presumably smart enough to figure things out without being told
> in the face, but I've seen too much "enterprise" code by now to not be
> cynical about it.)
>
>
> T
>

I do agree. However, I don't think this apply in any way to our case. 
out parameter is a C usage, and it is confusing in C, because, as you 
mentioned, you don't know if you pass the pointer because it is an out 
parameter, because you want to avoid copy, because something else . . .

The fact that better constructs (ie Tuples) exists in D make it already 
clear. And if the point is to fix C, it is useless because the whole 
thing is already confusing in C.


More information about the Digitalmars-d mailing list