Timothy S. Nelson wrote:
method foo() does assume<conserve_sum> { ... }
method bar() does ensure<conserve_sum> { ... }
Is "ensure" equivalent to the "assert" that you describe above?
Yes. "does ensure" was meant to be an englishification of
"postcondition"; and "does assume" is "precondition".
From the perspective of formal specification, one assumes that a
precondition is true, and the body of the method/sub/block must ensure
that the postcondition is true (given the assumption of any preconditions).
method baz() { bar; ok conserve_sum; foo; }
I'd suggest that we don't even need to have "ok" here; we'd be
better off just going "conserve_sum()", and assuming that, because it's
a property, the "ok" will be automatically attached. I know you're not
being picky about syntax at the moment, but I wanted to throw the idea
into the ring.
You really need some keyword there, to distinguish between the roles of
"assume" and "assert". Also, it provides a construct to hang other
traits on to. For example, I could conceive of a trait:
ok foo, :broken<rakudo>
which might downgrade the error to a warning on rakudo, but not on other
implementations.