From: Paul Dragoonis [mailto:dragoo...@gmail.com] 

> On Thu, Dec 22, 2011 at 6:41 PM, Rasmus Lerdorf <ras...@lerdorf.com> wrote:
>
> > On 12/22/2011 07:08 AM, Keloran wrote:
> > > i would love to see this expanded aswell (the way type hinting on
> > function
> > > variables was supposed to be), so that it could be
> > >
> > > string, int
> > >
> > > e.g.
> > > function int test(bool $tester) {
> > >  if ($tester) { return 5; }
> > >  return 99;
> > > }
> >
> > Return type hinting needs to be aligned with parameter type hinting, 
> > and as has been pointed out many times on this list, type hinting for 
> > interchangable scalar types is a really bad idea. It will push all 
> > type checking up to the caller of the underlying functions/methods. 
> > PHP is primarily a Web scripting language and the Web isn't typed. 
> > Having stuff like this break:
> >
> > if(age_check($_POST['age'])) { do_stuff(); }
> >
> > because the author of the age_check() function added an int type hint 
> > just doesn't make any sense. It would cause everyone to have to start 
> > casting things everywhere, just in case. eg.
> >
> > if(age_check((int)$_POST['age'])) { do_stuff(); }
> >
> > This is not a step forward. If the author of age_check() really 
> > doesn't want to accept type-juggled arguments, then it is easy enough 
> > to do a strict type check in the function itself. This puts the effort 
> > in the correct place and doesn't encourage this type of coding.
> >
>
> I agree with Rasmus.
>
> My opinion:
> This isn't java, if you want a strongly typed language, there's plenty out 
> there, but we're not looking to make PHP more like Java and the rest, if it 
> was like Java then it wouldn't have been successful for the web as it is/was. 
> PHP is popular because of the way it was from the start, if php _needed_ 
> scalar typehints then it wouldn't have been as popular.

> There is need for the existing Typehinting for class types so you don't need 
> to have is_a() function calls. This makes sense.

> Scalars are VERY powerful in PHP, because of its loose typed nature. Having a 
> 'numeric' typehint makes sense, because it can be an int, float, or string. 
> Adding typehints like 'int' and 'float' will only piss people off, and make 
> PHP more difficult and less fluent to code in.

> Lets not go there please..

> Thanks,
> Paul Dragoonis.
>
>
>
> >
> > -Rasmus
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, 
> > visit: http://www.php.net/unsub.php
> >
> >

Slightly off topic, but I keep seeing this problem:

"PHP is not language X" is a terrible argument. This is a smokescreen designed 
to insult the other person, belittle their concerns, and avoid discussing the 
real issue. This doesn't advance the discussion at all. 

Concluding that PHP is popular because you can't {insert requested feature 
here} is also ridiculous but it happens again and again whenever language 
features are discussed. PHP is popular independent of not {insert missing 
feature here}. It is popular because it was on the scene early, has good server 
support, and does an excellent job of making it trivial to handle most simple 
web requests.

Nobody wants to be told to shut up and go use language X.

Let's discuss things on their own merits.

/rant

John Crenshaw
Priacta, Inc.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to