Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2934 invoked by uid 1010); 2 May 2004 16:44:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 2884 invoked from network); 2 May 2004 16:44:04 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.185) by pb1.pair.com with SMTP; 2 May 2004 16:44:04 -0000 Received: from [212.227.126.162] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BKK4R-0006Su-00 for internals@lists.php.net; Sun, 02 May 2004 18:44:03 +0200 Received: from [80.139.7.215] (helo=[80.139.7.215]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BKK4R-0002uI-00 for internals@lists.php.net; Sun, 02 May 2004 18:44:03 +0200 Reply-To: internals@lists.php.net To: internals@lists.php.net In-Reply-To: <243202120.20040501220932@marcus-boerger.de> References: <243202120.20040501220932@marcus-boerger.de> Content-Type: text/plain Message-ID: <1083515960.331.84.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sun, 02 May 2004 18:39:21 +0200 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:e958292ea7b1c44e51b2b9ca0a9da460 Subject: Re: [PHP-DEV] [RFC] Type hints From: thekid@thekid.de (Timm Friebe) On Sat, 2004-05-01 at 22:09, Marcus Boerger wrote: > Hello internals, > > while working with php 5 the last days i find it more and more > annoying that we allow NULL with type hints. > From my perspective allowing NULL with typehints would happen > only very rare. I don't think this is true. I think there are a number of cases where passing NULL is used to "unset" or "delete" something. For example, say a class supports debugging using a listener model: class Foo { function setEventListener(Listener $l) { ... } } $foo= new Foo(); $foo->setEventListener(new ConsoleListener()); // ... $foo->setEventListener(NULL); This makes perfect sense to me and also gets rid of the constraint of having to define an "unsetEventListener" method. To wrap it up: Would you agree that being able to pass NULL to any pointer argument in C is annoying? [...] > 2) (Andi) introduce 'not null' after php 5.0. This won't introduce > a BC break. But it would require two new keywords 'NOT' and 'NULL'. > The latter is not a problem because it is a define at the moment > and the patch (a) shows that it easy to change it into a keyword. > The problem is the new keyword 'not' which would introduce a BC > break for everyone using the word 'not' already. I like this idea best: No magic such as "only when it is the first default argument" (the question "why" will inevitably come up sooner or later); plus no BC break. Concerning the new keyword argument, how about using the exclamation mark (already meaning "not"), as in: * function foo(Classname !NULL $val) { } The same as Andi's suggestion, but using ! instead of "not" * function foo(Classname $val !NULL) { } Ditto, but using postfix notation. Comes close to default value syntax which people are already used to. * function foo(Classname $val != NULL) { } This would be even more similar to the default value syntax. - Timm