RE: [PHP-DEV] Type hints with null default values
| From: | Robert Silva | Date: | Tue, 19 Oct 2004 21:33:29 +0000 |
| Subject: | RE: [PHP-DEV] Type hints with null default values | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-13401@lists.php.net to get a copy of this message | ||
Am I just being a goofball seeing a distinction between allowing a class
hint to accept null vs. it being an optional parameter?
Both Todd's and Marcus' replies seem to indicate otherwise.
Bob
-----Original Message-----
From: Marcus Boerger [mailto:helly@php.net]
Sent: Tuesday, October 19, 2004 1:37 PM
To: Robert Silva
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] Type hints with null default values
Hello Robert,
Tuesday, October 19, 2004, 10:20:59 PM, you wrote:
> The issues surrounding this seemed to have been muddied up a little, I'll
> try to clear them up.
> I see two different sets of functionality that people are asking for.
> #1. The ability to pass null on a type hinted param (but still a mandatory
> param)
> #2. The ability to define an optional type hinted param.
> I see it as a very important distinction to make. Using the #2 to solve #1
> is not the solution PHP should implement. Using some method which operates
> on the class hint itself is the right solution.
> For example, using the [] method:
> public function Compare([BaseClass] $objA, $cmpFunc);
As far as we disallow this and only allow optional types at the end i'd
agre to this. Example:
public function Compare($cmpFunc, [BaseClass] $objA);
> If we were to use the optional parameter method to solve #1, then you
limit
> the language unnecessarily.
> public function Compare(BaseClass $objA=null, $cmpFunc); <-- Error!
> That would be a mistake, IMO, to put that restriction on the language.
> Thanks for all the feedback you guys are providing, together we should be
> able to come up with a solution that meets everyones needs.