Hi Yasuo,
> 
> Now I understand what you are discussing. Since we may have stricter
> typing, we probably better
> to consider type safety theory even if PHP is weakly typed.

I am not sure it was about types, it was about conditions...

> Pre/Postconditions should be checked only when parent method is called.
> That's what Eiffel does.
> Eiffel does not allow method overriding. Therefore, pre/postconditions of
> methods (not invariants.
> Invariants inherited implicitly(automatically) both Eiffel and D are
> evaluated except certain
> methods) cannot be evaluated automatically unless parent method is called.

I agree for pre-conditions, but not sure for post-conditions.

> Since children's method may have whole different way of handing
> parameters,
> including swapping parameter order, adding/removing parameters, etc.
> Parameters cannot be checked automatically unless we have some kind of
> binding system that bind child parameter to parent parameter. Even if we
> have
> it, parameter for parents may be generated in function body. It cannot be
> perfect.

I hadn't thought about this. Parent and derived methods can have different 
signatures.

So, you mean we cannot inherit pre/post-conditions in any way.

But what about interfaces, as the signature matches there ? The interface case 
is complex, as a class can implement more than one interface and interfaces can 
be extended, providing the same potential problems as multiple inheritance.

The parent's post-conditions should be checked too, but in the parent scope, 
which is probably impossible (using parent argument names). To solve this, we 
can split post-conditions to two sets : those which deal with the return type 
and value only, and those that check other conditions (passed by ref args, for 
instance). Then, the parent's post-conditions which deal with return value only 
can be checked when the derived methods exit.

> Basic rule is we shouldn't be able to modify parent contracts(invariant,
> methods pre/postconditions).
> If we can change it, it's the same as changing type.  Your discussion
> applies to invariant and this
> is what you write, I suppose.

I am not sure I understand what you mean with 'modify parent contract'. If you 
mean that we must apply total inheritance for invariants, I agree.

> The same rule for class applies to interfaces.

?? I don't understand.

> We cannot ignore parent class invariants. If developer violate parent
> property restrictions,
> it's violation of parent class type and this must be forbidden. It's
> checked by invariant contract.

I agree.

Regards

François



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to