If it makes any difference...

I would say no way to multi method dispatch. PHP, in my understanding, was a loosely typed language, and this is straining against that very concept. In the rare case that one needs multi-method dispatch, they can use a format such as:

class xyz
{
    public function Foo($p1 = NULL, $p2 = NULL)
    {
        if($p1 instanceof Bar && is_numeric($p2))
        {
            //do something or
            return $this->Foo_Bar_Int($p1, $p2);
        }
        elseif($p1 instanceof OtherBar && is_null($p2))
        {
            //do something or
            return $this->Foo_Otherbar($p1);
        }
    }

...

}


~Jason



At 4/21/2004 07:32 AM +0200, Michael Walter wrote:
Christian Schneider wrote:
Sebastian Bergmann wrote:

  Since we introduce class type hints in PHP 5.0 I think it would be a
  good thing [tm] to add multi-method dispatch in PHP 5.1.

Actually I think multi-method dispatching for PHP is A Bad Thing[tm].
Multi-method dispatching is necessary for statically checked, inflexible languages without default parameters like Java.
That's probably why Common Lisp, a language way more dynamic than PHP, provides you with a complete implementation of multiple dispatch. How exactly do you think are default parameters related to the issue, anyway?

PHP has other means of handling the most common problems this tries to solve and having two methods of the same name is more confusing than helping IMHO.
I assume you are you aware of what dynamic dispatch is trying to solve -- could you give an example of the 'other means' you are referring to?

Cheers,
Michael

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

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



Reply via email to