Re: [RFC] Type hints
| From: | Ferdinand Beyer | Date: | Mon, 10 May 2004 16:01:12 +0000 |
| Subject: | Re: [RFC] Type hints | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9796@lists.php.net to get a copy of this message | ||
On 10 May 2004 at 11:31, Jason Garber wrote:
> The only way I see that as being useful is to be able to assume
that you
> can safely say $bar->DoSomething() from within your function
WITHOUT
> FIRST HAVING TO write an if() statement that verifies that it is not
null.
On the other hand in many situations it is useful to be able to pass
an empty value, e.g. setHandler(HandlerClass $a) could be called
with setHandler(null) to remove the handler.
For string values you can pass an empty string, for numbers 0 or a
negative number and for objects null.
In other languages it is always possible to pass null instead of the
object (e.g. Java), in C/C++, every pointer may be set to null.
I agree that it is a bad idea to introduce another weird syntax. We
should either always allow null or never. I would prefer the first
solution but could easily live with the second.
--
Ferdinand Beyer
<fb@fbeyer.com>