On Sun, Mar 01, 2015 at 05:22:05PM +0000, Rowan Collins wrote: > On 1 March 2015 15:18:09 GMT, "S.A.N" <ua.san.a...@gmail.com> wrote: > >Maybe better implement for method calls on primitive types in PHP 7? > >https://github.com/nikic/scalar_objects > > We'd have a whole bunch of tough decisions to make - does HTML escaping > really belong as a method of the string type? What are printf and scanf > methods of? Etc > > Without the ability for a user to patch the existing type (a major departure > from current classes), you basically still have a bunch of function aliases. > What motivation would there be to change dozens of instances of strpos($a, > $b) to $a->indexOf($b)?
This could be implemented but the existing functions (eg strpos()) could be left. This would set the model for new functions on basic types, etc, to be implemented as methods. If replacing strlen($str) by $str.length is really wanted, then allow a very long cross over time so that people do not need 2 versions of their code: 1 for method calls & the other basic functions. Thus if this were implemented in, say, PHP 7 warnings would be generated by default in PHP 9 and removal in PHP 11. It would, however, almost create a new language ... or what feels like a new language. > In this respect, some version of UString makes more sense, because (if > well-defined) it actually gives users some advantage over the current > functions. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php