Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13471 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29213 invoked by uid 1010); 22 Oct 2004 17:41:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27479 invoked by uid 1007); 22 Oct 2004 17:41:24 -0000 Message-ID: <20041022174124.27478.qmail@pb1.pair.com> To: internals@lists.php.net Date: Fri, 22 Oct 2004 14:41:24 -0300 Lines: 57 User-Agent: KNode/0.7.7 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit X-Posted-By: 200.252.148.190 Subject: RE: [PHP-DEV] Type hints with null default values From: cunha17@uol.com.br (Cristiano Duarte) Marcus Boerger wrote: > 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); > I don't see any danger if we allow null with this syntax:  public function Compare([BaseClass] $objA, $cmpFunc); if we don't allow null with this syntax:  public function Compare(BaseClass $objA, $cmpFunc); and if we make an argument optional with this syntax:  public function Compare($cmpFunc, BaseClass $objA=null); If someone (like me) has thousands lines of code that uses 'null' meaning 'null reference' just need to use syntax #1. If someone is very strict and don't even think about using null in typehinted arguments, because null is not a value it's a type and must be used as so, just need to use syntax #2. If someone wants to make typehinted parameters optional, just use syntax #3. I really don't see any problem allowing this three syntaxes(but I'm not very clever since I'm for syntax #1) :-P Regards, Cristiano Duarte