Re: optional type hinting enhancements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Török Alpár wrote:
I see a problem with this. Scalars are automatically casted by PHP based on
a set of rules. In  case of  a scalar type hint, would jo issue an error, or
make the automatic type cast?   both approaches have there advantages, but
the automatic cast, would go better with the actual features of the
language, but in this case, object could also cast an array to stdClass, and
i am not sure that's how you imagined it. Besides this i am not against it
along as it doens't create implementaion nor performance problems, and this
problem is solved.

I see what you mean with the casts; and a very good point on why scalars aren't already implemented..

On the one hand i see scope for a set of primative wrappers (class String, Integer, Boolean etc) which those who wished could use (with an auto cast).

Whilst on the other hand it could be argued that the current is_xxx functionality could be copied so an integer in a string is still a string, likewise 1 is an integer not a boolean true etc etc.

defintaly needs some thought and practical examples though.. rfc time one thinks.

with the specific array example, this is already implemented so no problems there, what is not implemented though is the ability to function(object $obj) which seems strange.

as for the error, same as it is currently E_RECOVERABLE_ERROR and def not automatic type casting; last thing you want when trying to be strict is anything like that :p

thanks for the input!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux