Re: [RFC] Type hints

From: Date: Mon, 10 May 2004 16:31:29 +0000
Subject: Re: [RFC] Type hints
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-9799@lists.php.net to get a copy of this message
Hi Marcus, You are totally correct. I should have clarified my statement on the default parameter vs allowing nulls as they are very different. To sum it up, as Andi said: "I think the best solution for now is not to allow null in the regular type hint syntax, and have people who want to allow NULL's not use type hints at all..." +1 __________________________________________________________ Jason Garber President & Chief Technology Officer IonZoft, Inc. 814.742.8030 :: jason@ionzoft.com :: http://IonZoft.com __________________________________________________________ At 5/10/2004 06:24 PM +0200, Marcus Boerger wrote:
Hello Jason, Monday, May 10, 2004, 5:31:38 PM, you wrote: Hello, I've been following this discussion from the beginning. To be pointed, I think that the whole matter is rather a serious case of "overfunctionality". Consider allowing a type hint such as function foo(MyClass $bar) 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. Even allowing null as a default parameter is somewhat disturbing. The programmer should ditch the typehint if he needs any behavior other than the one described above, and use a simple if() statement to find out if it is the correct class. Until here i very much agree. To clearify: The reason i provided all the patches is that i simply want the descibed behavior as default and if at all a syntax addition to allow NULL explicitly. If it is deemed necessary to allow a NULL default parameter, then let's keep it simple - function foo(MyClass $bar = NULL) As i pointed out before this solution comes with a slight disadvantage and it also contains some magic. It is simply semantically very different from secifying the allowed types and setting a default value. Combining them is therefore magic that is hard to understand. IMHO, PHP has always been a language that can be used very simply, but still has the low-level power to accommodate all the other things that one wishes to accomplish. Let's keep it that way. Yes we have very good solution which one must not use. In C++ or Java you are forced to use all the syntax or you will fail. best regards marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#9799) next »