On Wed, August 2, 2006 4:00 am, Stefan Walk wrote:
> For the people who have said "I can not understand why this is a bad
> thing":
>
> http://en.wikipedia.org/wiki/Liskov_substitution_principle

Unless I'm mis-reading pre/post condition strictures...

Given PHP's cheerfully acceptance of additional arguments to
non-existent parameters:

NOT KOSHER:
class a {function f(){}} class b extends a {function f($a){}}
$a = new a;
$b = new b;
$b->f();

Here, the instance $b of b, a subclass of a, cannot have ->f() called
with 0 args without issuing a E_WARNING.
So it violates the substitutability of the subclass.

This, however, seems KOSHER to me:
class a {function f($a){}} class b extends a {function f(){}}
$a = new a;
$b = new b;
$b->f();

So, strictly-speaking, the reference only requires that subclasses
have "more general" parameters than the superclasses.

All of this seems moot, however, unless we have, or plan to have,
software to prove the correctness of PHP scripts.

Writing such software, to demonstrate that a PHP script is "Provably
Correct" with dynamic typing, seems to me like it would be an
NP-incomplete problem, and a non-starter from the get-go...

It's been a long time since I've done any "Provably Correct" research,
but I don't think that the state of the art has changed that much in
this regard -- A few thousand software developers I know would have
been blogging for months if this had changed.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

Reply via email to