Magnus Lie Hetland: > Yeah, that's what I've got right now. Just seems odd to need to use > attributes for this sort of thing. Also, it's rather brittle -- for > example, if the function (directly or indirectly) calls itself. Then > two (or more) pairs of in/out blocks will manipulate the same > attribute... Seems like a variable that would be local to one specific > in/out instantiation (or stack frame) would be preferable. > > I guess I could just use a local variable (guarded by version()) and > then have an assert() near the end of the function. Probably a better > solution...
Your need is perfectly natural it's named "old" values or prestate in contract programming, and currently it's probably the biggest hole in the D contract programming. It was discussed three or four times, like: http://www.digitalmars.com/d/archives/digitalmars/D/why_no_old_operator_in_function_postconditions_as_in_Eiffel_54654.html http://www.digitalmars.com/d/archives/digitalmars/D/Communicating_between_in_and_out_contracts_98252.html I don't know if Walter is willing someday to fill this hole of the D DbC. In my opinion is good to bugger now and then the main D newsgroup about this, to help Walter&Andrei understand that there are some programmers that care for this feature of DbC. Bye, bearophile