Re: Re: [PHP6] Function name consistency

From: Date: Fri, 24 Jan 2014 20:27:02 +0000
Subject: Re: Re: [PHP6] Function name consistency
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-71526@lists.php.net to get a copy of this message
Hi Larry,

On Fri, Jan 24, 2014 at 10:11 AM, Larry Garfield <larry@garfieldtech.com>wrote:

> On 1/23/14 1:31 PM, Rowan Collins wrote:
>
>  Therein lies the whole problem with adding more aliases - it just makes
>> things more inconsistent, as developers can use (deliberately or
>> accidentally) different names for the same function.
>>
>> I still have to think a moment when I see sizeof() or print, rather than
>> count() or echo - let alone having to remember which version of PHP
>> introduced which alias so that libraries don't break when deployed to
>> older servers.
>>
>> I think it's far better to have replacements for whole sets of functions
>> that are clearly "new and shiny" - be that OO strings and arrays, or
>> just namespaces for extensions like mbstring. In fact, a namespace for
>> mbstring could allow a much cleaner version of the "override normal
>> string functions" system, because you could just "use" the namespace,
>> and have functions with overlapping names...
>>
>> Regards,
>> Rowan Collins
>> [IMSoP]
>>
>
> Agreed.  Simply aliasing a bunch of functions offers no useful value, but
> does increase confusion.  ("Wait, do I use strcmp() or string_compare() on
> this project?  What version are we on again?  Oh, look, this library uses
> both.  Must have been different devs.  FML.")
>
> If we're going to do anything, be aggressive and far-reaching with it.
> Build a proper language-level OOP design for string/array manipulation.
>
> We have enough functions lying about.  Don't add more.


We should be careful choosing names. I agree.
However, not adding more function names is simply impossible.
For example, I'm about to add new session function named

string session_create_id([string $prefix])

for user save handlers, so that user could generate secure ID
easily. It's a straight name for session ID creation and there
might be users using this name.

Not adding any new names means not adding any new features
nor cleanups.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net


Thread (46 messages)

« previous php.internals (#71526) next »