Re: Redefine to make a contract stronger (Was: is_equal ofHASHABLE)

Frank Boehme <[email protected]>
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
Roger Browne wrote:

> > But what if we redefine an *effective* feature for the sole purpose to
> > make the contract stronger...
> > class C
> > inherit A B
> 
> This works already. Just write:
> 
>    class C
>    inherit
>       A
>       B undefine f end
>    end
> 
> C will get f's postcondition "and-ed" from both A and B, as you would
> expect.

Ah, of course yes. I did not think of that. I am currently writing a
library for binary relations, posets and the like (not actually
trivial). I have a general relation class (lets call it R) and a number
of more specified ones that inherit from R (conforming). These are
REFL_R (reflexive relations), IRR_R (irreflexive), SYM_R (symmetric),
ANTSYM_R (antisymmetric) and TRANS_R (transive relations) to name but a
few. All these classes do not change anything but adding postconditions
to already existing features from R which provide concatanation,
reversion etc. Of course, it is very common to inherit from more than
one of these. For example, LESS_THAN should inherit IRR_R, ANTSYM_R and
TRANS_R. For some other reasons, I do not want to have any of these
classes deferred which means i habe to follow your first suggestion.
Now, it might be a little counterintuitive to have something like

class LESS_THAN
inherit
  IRR_R undefine .... end
  ANTSYM_R undefine .... end
  TRANS_R
...

It does not matter which of the parents has no 'undefine' but there must
be exactly one. A little odd, given the fact that LESS_THAN *is*
irreflexive, antisymmetric and transitive and all of these three
properties are equally significant. But i think I will go this route.
Thanks.

> > But I am not proposing how this could be added to, errrrm...
> > the SmartEiffel.. ahmmm language(?).
> 
> Luckily, it turns out that it's already there.

No no, I strongly advocate the new keyword 'recontract'! We do need
this! :-))

F

-- 
Dr Frank Boehme                      | Email: [email protected]
National University of Ireland, Cork | phone: +353-21-4903163
Dept of Computer Science             |   fax: +353-21-4903113
Cork, Ireland                        |

Did you know that if you play a Windows XP cd backwards, you
will hear the voice of Satan?
That's nothing! If you play it forward, it'll install Windows XP.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.