"Before and after" in contracts?
Magnus Lie Hetland
magnus at hetland.org
Mon Apr 11 07:36:25 PDT 2011
On 2011-04-11 16:32:36 +0200, Kai Meyer said:
> I don't know if I can speak to the philosophical points here, but you
> can put your attribute declarations in a version block, and as long as
> the usage of that attribute is only used when that version is used, you
> should be fine.
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...
--
Magnus Lie Hetland
http://hetland.org
More information about the Digitalmars-d-learn
mailing list