why no "old" operator in function postconditions, as in Eiffel?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Jun 22 02:03:20 PDT 2007


Bruno Medeiros wrote:
> For D to properly support 'old', D would need to clone any input used as 
> old, and that sounds as it might have some issues (not sure about that 
> though). Still, perhaps better would be the alternative presented in the 
> .learn thread where the 'out' scope would be able to access the 'in' scope.

I don't think cloning is necessary. It would just need to evaluate the 
old-expression before the body is entered (i.e. at the end of the "in" 
clause) and save the result in an "invisible variable" that's accessed 
where the old-expression appears.
Of course, it's then the programmer's responsibility to make sure that 
the result is still valid after the body has executed; if it for 
instance slices an array that's modified in the function, manual dups 
will be required.



More information about the Digitalmars-d mailing list