On Feb 20, 2013, at 11:19 , Sebastian Krebs <krebs....@gmail.com> wrote:

> 2013/2/20 Klaus Ufo <klaus...@yahoo.fr>
> 
>> Hi there !
>> 
>> We all know that the current PHP API has flaws. Maybe we could use
>> namespaces to build a new coherent PHP API ? Like :
>> 
>> - \arr
>> - \num
>> - \str
>> 
>> and so on. Advantages :
>> 
>> - no more global functions
>> 
> 
> Just to throw that in: Even if you pack them into namespaces they will
> still remain global functions. They simply don't live in the root-namespace
> anymore.


+1

So why not avoiding this by adding it as methods of the scalar variable 
instead, aka autoboxing.
This would allow the new api to be closer to what people are used to from other 
languages, needs far less typing and IDE autocomplete of available functions pr 
type with "->".

More recent example by Nikita Popov, see unit tests of the project for examples:
https://github.com/nikic/scalar_objects/blob/master/tests/string.phpt#L17


> 
> 
>> - separation of concerns
>> - backward compatibility
> 
> - work can be done progressively
>> - easy to add user-defined functions (using php namespaces)
>> - we could provide a \str\utf8 namespace
>> 
>> This is just an idea. I don't know what is your vision for a next PHP 6.
>> 
>> KH
>> 
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 
> 
> -- 
> github.com/KingCrunch



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

Reply via email to