Re: Q on Primitives

From: Date: Thu, 18 Dec 2008 11:59:14 +0000
Subject: Re: Q on Primitives
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-42327@lists.php.net to get a copy of this message
Nathan Rixham wrote: > [...] > > while I'm here I may as well also ask about further adding type > hinting for the existing scalars and array. +1, but I don't know what might have stopped it being implemented before (time, parsing API changes, etc), so it would be interesting to look into the history. > and finally different method signatures such as: > > class Whatever { > public function __construct(Bar b); > public function __construct(Foo f); > public function doSomething(Bar b); > public function doSomething(Foo f); > } +1. Having overloaded function definitions like this would be very useful, but I don't know how awkward it would be to implement - I don't know how the function pointers are currently stored. I could imagine adding information about the type signature to the internal method name, and looking up based on that... but then I don't know how it's stored so I might be talking rubbish! Also, what about this case: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } I would argue that the most specific function should be called, but how costly would that be to determine? What if you have a "Baz" subclass of Bar, but no corresponding method? What if Bar itself is a subclass of Foo? Dave

« previous php.internals (#42327) next »