On 25/02/2016 23:48, Alain Rastoul wrote:
@Stef, Alexandre, Damien, Nicolai, Stephan,
Thank you for the discussions, pointing me errors and interesting link.
I understood that the concept and/or it's implementation seems a bit
obscure, partly because of the syntax I've chosen for pragmas.
I will conform to some naming standards : #invariant/#pre/#post/on: will
be clearer than #required/#ensured/appliedTo:.
<contract: #invariant>
...
<contract: #pre on: #aMethod>
...
<contract: #pre on: #( #aMethod1 ... #aMethodn)>
...
idem post:
<contract: #post on: #aMethod>
...
<contract: #post on: #( #aMethod1 ... #aMethodn)>
...
I also note the suggestion of Damien (putting the pragma contracts in
the methods) but I am not truly convinced and it would imply some
rework, so I will not do that now - perhaps after a try.
examples
fooContract1
<contract: #invariant>
^ myState notNil.
fooContract2
<contract: #post on: #foo>
...
postAdd: anObject
<contract: #post on: #(add: #addLast:)>
^ self includes: anObject
etc.
--
Alain