Re: Return type hints

From: Date: Tue, 08 Apr 2008 10:54:06 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-36868@lists.php.net to get a copy of this message
Actually nothing could support my point about giving the wrong signals better than these two postings: They are IMHO on the wrong track on how to make an interface better. Krister Karlström wrote: > This is maybe getting a bit out of topic now, but what about > function/method overloading using type hinting: > > function myfunc(string $data) { } > function myfunc(int $data) { } > function myfunc(myClass $data) { } <sarcasm> Go back to Java please ;-) </sarcasm> > Arvids Godjuks wrote: >> I think type hint's would be good optional functionality. Those who need >> will use it, others will not. I'd probably use it in some cases. >> Especially if named parameters are implemented. >> >> Sometimes what I really want is named parameter pass like >> >> function myfunc(array $array, string $string = null, int $someint = 0){ >> } >> >> myfunc($myArray, someint = $mySomeInt); While I think named parameters are a good idea I pointed out in older postings that I think this is a very crippled approach to it: You still have to define all the parameters you are going to accept. The real power and flexibility comes in if you accept (and handle) arbitrary argument lists. <plug> See http://itools.search.ch/ for an example of what I mean. </plug> Okay, enough evangelism for today, back to work :-) - Chris

« previous php.internals (#36868) next »