Who favors the current D1 situation?

Walter Bright newshound1 at digitalmars.com
Thu Mar 6 23:38:43 PST 2008


Kris wrote:
> As one of the early proponents of const (actually, a subset of const), I 
> have to admit to being disappointed with the current D2 mechanisms. Have 
> avoided commentry in the past, because D2 has been positioned as merely 
> experimental. However, from what I understand, Walter is feeling like the 
> const design is almost baked.

That's right, although there have been bugs in the implementation (many 
were fixed in the 2.012 update).

> My original beef was not being able to protect a return value (such as a 
> char[]) from being abused without having to copy the returned content 
> instead of returning a slice. At the time, the 'in' modifier provided 
> suitable intent and control for read-only parameters, so the /hope/ was for 
> something reasonbly simple (to the user) in order to handle the return-value 
> aspect.

If you ever find yourself needing to dup an invariant array, there's a 
bug somewhere else in the code.

> While I understand how things can sometimes quickly become complex while 
> trying to support a simple notion, there's nothing trivial at all about 
> using or comprehending the D2 const mechanisms. A claim has been made that 
> one does not have to use or be aware of const or invariant to use D2 ... 
> unfortunately that does not appear to be the case in practice, and the added 
> complexity makes D2 harder to work with than D1.

In some ways it is more complex, but in other ways it is simpler. Not 
the language, but the way it is used. For instance, you shouldn't have 
to be worrying about defensively duping invariant arrays.



More information about the Digitalmars-d mailing list