Unofficial wish list status.(Jul 2008)

superdan super at dan.org
Tue Jul 22 19:33:45 PDT 2008


Sean Kelly Wrote:

> Walter Bright wrote:
> > Sean Kelly wrote:
> >> I personally feel that requiring that parameters be const is 
> >> sufficient for memoizing results.  Requiring invariance assumes a 
> >> programming model that I simply don't endorse.  But I'll grant that 
> >> it's certainly the safer approach.
> > 
> > What such a an approach would rely on would be the *convention* that 
> > nobody would change the referenced const data from one invocation of the 
> > function to the next. This contradicts the whole premise, and is no 
> > better than C++.
> 
> Oops, you're right.  I was thinking simply of the data changing while 
> the function was executing.  I suppose requiring invariance of 
> parameters does make sense.
> 
> 
> Sean

that's one interesting about d's const system. looks like there's extra shit that you wouldn't need, but as soon as you take any out you're fucked. i'm not sure it's enough yet, from what i can tell invariant object construction is a grandmotherfuck. but sure there's no fat in the system right now.

reminds me of the kon tiki expedition i saw when i was a kid. this guy thor heyerdahl reproduced an ancient expedition in a boat made of bamboo or something. he made it like in antiquity, but there was an extra rope at the front that he found unnecessary. so he was like, fuck that rope, don't put it in. sure as shit, in a few weeks' time the bamboo boat was bending and sinking exactly where the rope would have held it properly in place. for some reason that particular story stayed with me ever since.

const is the rope that keeps invariant shit and mutable shit together. without const there'd be like two worlds separated by a ridge. that system would be fucked. without invariant the system would be like an eunuch: sees a lot of good stuff goin' on but can't do shit about it because it's powerless. (that's c++ by the way.) with const there's two worlds that can communicate.



More information about the Digitalmars-d mailing list