Chuck wrote:I know Eiffel puts the ensure last to reflect the order of execution, but Cobra puts the body last to separate the interface from the implementation. The "body" is the implementation and everything else (test, require, ensure) is interface.
So try putting it up higher and let me know if you have any other problems.
Thanks, it works indeed when "ensure" is placed before "body". For some reason I was assuming that, since "invariant" could be placed anywhere inside a class, it was the same with method contracts. But you're right, I think it's better to have the interface on top and the implementation last.
Chuck wrote:Let me know if the error message needs to be improved.
The actual error message I got was:
DelegateBug.cobra(5): error: DelegateBug.cobra(5,9): error: Expecting DEDENT, but got "ensure" instead.So yes, I guess the compiler could detect that I've written "ensure" instead of any other random symbol, and say something helpful like "ensure, test and require must be placed *before* the body of the method"