On 3/2/15 4:50 PM, Rowan Collins wrote:
On 02/03/2015 22:36, Yasuo Ohgaki wrote:
I like scalar objects, but it does not resolve that PHP has non standard
function names.
It does not change old names, therefore it's impossible to resolve issue.
This is the reason why I'm proposing while I like scalar object, use of
namespace, etc.

Again, you're contradicting yourself here - you can't say that your
mission is to change the old names, rather than offer an alternative,
but then also say that the old names will stay around forever. If both
names exist, that's exactly what you've created - an alternative.

If we're going to have an alternative, let's come up with a creative
alternative that actually has an advantage to using it, not a choice
between equally cryptic names like "strripos" vs "str_ripos".

Regards,

Exactly. If a PHP 7 dev has the option of:

$s = strripos($s, 'a'); // works in PHP 5+

$s = str_ripos($s, 'a'); // works in PHP 7+

Really, what's the advantage of the latter? Nothing. It's an extra character to type, limits compatibility, and makes my life no easier. It's useless, and will just add to the list of things people make fun of PHP for instead of reduce it.

Namespacing it is no better:

$s = str\ripos($s, 'a'); // Still useless
$s = php\str_ripos($s, 'a'); // Still useless


Instead, compare:

$s = strripos($s, 'a'); // works in PHP 5+

$s = $s->lastOccurance('a', 0, CASE_INSENSITIVE); // works in PHP 7+

Oh now we're talking! That's more self-documenting, easier to discover, makes chaining string manipulations easier to read, solves the needle/haystack issue, and reduces cholesterol.

One is worth the effort of doing.  The other is simply not.

For subsystems that aren't clear scalars, like streams, those need a general overhaul for DX, too. Again, just doubling the number of function names adds nothing to the language but confusion, since both versions would have to live for at least the next decade. Offering a substantially better alternative does improve the language. Don't waste your time on marginal not-even-improvements.

--Larry Garfield

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

Reply via email to