Unofficial wish list status.(Jul 2008)

Sean Kelly sean at invisibleduck.org
Tue Jul 22 17:14:43 PDT 2008


Bill Baxter wrote:
> On Wed, Jul 23, 2008 at 8:27 AM, Brad Roberts <braddr at puremagic.com> wrote:
>> On Tue, 22 Jul 2008, Walter Bright wrote:
>>
>>> superdan wrote:
>>>> i couldn't design an const/invariant system to save my life
>>>> from the same cannibals who ate bjarne. the space looked like a zero
>>>> sum shit to me. so when i saw what walter came up with, i was rightly
>>>> surprised. same goes about some shit in phobos2. it's not just yet
>>>> another library. it's a fucking cool one because it's better in a new
>>>> and surprising way.
>>> I cannot claim credit for it. The const/invariant design was the result of
>>> literally hundreds of hours of work (and maybe a hundred gallons of coffee) by
>>> Andrei, Bartosz, Brad, David, Eric and myself, as well as feedback from the
>>> community on why our earlier efforts got it wrong.
>>>
>>> The transitivity requirement originated with Andrei, if I recall correctly.
>> Quite possibly it was both of us, but I know I brought it up in
>> discussions with you prior to joining the group discussions.  It's my
>> primary angst with c++ const.
> 
> By that do you mean something that's caused you actual trouble in C++
> projects?  Or just something that keeps you awake at night worrying
> about the trouble it could cause?  My feeling is that C++ const does a
> decent job in practice of preventing programmers from doing stupid
> things.  On the other hand, if you're trying to go out of your way to
> be stupid... that's another matter.  But for the most part, while it
> may be easy to circumvent const, it's not so easy to circumvent it
> accidentally.  Useless for making compiler optimizations, yes, but
> fine for documenting the intent of code.

I think one salient difference between C++ and D related to this is that 
objects are reference-based in D and thus would be mutable by default 
given the C++ const rules.  One could argue that the compiler could 
apply the const-ness of the containing object to object members, but 
good sense would dictate that const-ness should apply identically to all 
reference-based members rather than making object members a special 
case.  And at that point you've got transitive const :-)


Sean



More information about the Digitalmars-d mailing list