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:
-
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.
-
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'
?>
-
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
-
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
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.
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:
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.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' ?>
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 Gocasting 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