An old topic (pun intended)

Jonathan M Davis jmdavisProg at gmx.com
Sun Oct 16 23:04:41 PDT 2011


On Monday, October 17, 2011 00:29:30 Timon Gehr wrote:
> On 10/16/2011 07:31 PM, Jonathan M Davis wrote:
> > On Sunday, October 16, 2011 19:13:09 Timon Gehr wrote:
> >> I don't agree that 'old' is very difficult to implement. Just evaluate
> >> what is inside the 'old' before you enter the in contract, store
> >> somewhere, maybe in hidden local variables, and make the data
> >> available
> >> in the out contract. Eiffel's 'old' does not do more than that.
> >> 
> >> (but perhaps there are implementation details in DMD that make this
> >> more
> >> difficult than necessary. I don't know.)
> > 
> > What if you're dealing with a class? You'd need to deep copy the entire
> > object for it to work. There's no way built into the language to do
> > that (not to mention that it would be horrifically inefficient).
> > 
> > - Jonathan M Davis
> 
> Eiffel does not do that either.
> (even though it _does_ have a built in deep copy feature)
> 
> We don't have to over-engineer the feature, if somebody needs to
> deep-copy an object they can implement it themselves and use
> old(obj.deepCopy()).

I don't see how you could really expect to test the current state against the 
initial state when you don't actually save the initial state. And as far as 
implementing it yourself goes, you could go and do that that right now. You 
don't need compiler support to save the initial state somewhere and then test 
against it afterwards. It's just nicer if the compiler gives you support for 
it.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list