One consideration: Should be a general array/string/int/float/bool API. PHP
is weakly typed: therefore, say, reverse() would reverse a string OR an
array. negate() would invert a bool, negate an int/float. slice() would
slice a section of a string OR an array. max() would find maximum of an
array, or max() of two numeric values, etc. If you get my meaning. These
are all examples of course. Many functions would have to be type-specific
(numeric, array/string, boolean, array, string), but they should be
multi-type as far as possible IMO.
On Jul 19, 2012 9:06 AM, "Alexey Zakhlestin" <indey...@gmail.com> wrote:

> Stas made a good point about need to start with new API, which then can be
> followed by syntactic sugar.
>
> So, we need some ideas to start with:
>
> 1. A lot of people told, that it would be a good idea to come with a
> written standard regarding arguments order. I don't care what it will be,
> as long as it will be documented.
>
> 2. It would be really useful to have 2 versions of each function: one
> which mutates the variable and one which returns the new variable.
>
> Example:
>
>     <?php
>       $src = 'SoUrCe';
>       $result = lowered($src); // $result == 'source', $src == 'SoUrCe'
>       $result = lower($srd);   // $result == true,     $src = 'source'
>     ?>
>
> 3. Speaking of implementation… Functions, which return slice of
> string/array could be made to reference the same memory-areas as the source
> strings/arrays. That is until the first modification, of course. Kinda
> advanced copy-on-write semantics. I know something like that is implemented
> in D http://dlang.org/d-array-article.html and Go
>
> 4. casting between strings and arrays of characters would be a great thing
> to have too. this way, useful array-oriented functions could be applied to
> strings

Reply via email to