The Artima Developer Community
Sponsored Link

Is inheritance of semantic constraints a problem?

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Is inheritance of semantic constraints a problem?

Posted by John Rivett-Carnac on 30 Nov 1998, 3:13 PM

>Mike Mannion wrote
> For example, suppose Java should one day fully support Design by Contract. Full support would allow us to go beyond a mere method signature in a Java interface and make it possible to specify semantic constraints (pre- and postconditions). Such constraints must, of course, be inherited, but what happens if two interfaces specify two distinct (potentially conflicting) sets of semantic constraints for methods sharing the same signature?

Although the semantic constraints may differ, there is still only one implementation, which would presumably have to be written to comply with all the constraints from all the interfaces which have the same method. If the constraints are mutually exclusive, then you cannot implement the method - i.e. the interfaces are mutually exclusive, so you cannot mix them. I am no expert in the expression of semantic constraints, but wouldn't it be possible for the compiler to check that the constraints for the same method in two interfaces are not conflicting?




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us