Who favors the current D1 situation?

Walter Bright newshound1 at digitalmars.com
Fri Mar 7 01:31:38 PST 2008


Kris wrote:
> It is simpler and generally more effective to design an API which avoids the 
> .dup issue.

But you shouldn't *need* to be doing .dup for invariant arrays. If you 
are duping them, there's a problem somewhere else in the code.

> Usage of dup (and idup) is not a good poster-child to hold aloft, when they 
> can be avoided in the vast majority of cases. For example, in all of Tango 
> there's only one instance where a const return would be nice to have, due 
> mostly to an avoidance of the situation. The usage of  D1 'in' can suffice 
> for all read-only parameters. Tango is a large body of code, as you know, 
> with attention given to efficiency. One might hope the highly narrow scope 
> therein for D2 const/invariant might indicate something of value for you --  
> perhaps that const/invariant might slip into a "special consideration" usage 
> instead? If it simplified the syntax and/or usage, a lot of people would be 
> jumping into D2 instead of remaining with D1

You can write bug-free and perfectly correct programs without const or 
invariant at all. But once a code base exceeds a certain level of size 
and complexity (and I don't know what that level is), const/invariant 
will become increasingly valuable. People who do work in large 
corporations managing extremely large codebases with legions of 
programmers working on them have made this abundantly clear to me.

> What I'm saying is effectively this: you don't have to solve all the const 
> cases to still have a stupidly-effective language. The tradeoffs to get 
> there so far are, imo, too costly in areas of comprehension and usability - 
> two huge factors in the attraction of D in the first place. Some folks might 
> disagree, and that's cool.

Part of the problem with const/invariant in D is we burned a lot of 
goodwill with the two previous designs that fell short of the mark. But 
I believe the design now is a sound one (despite the bugs in 
implementing some of the details, many of which were fixed in the latest 
update).



More information about the Digitalmars-d mailing list