Re: Flexible function naming
On Mon, Dec 16, 2013 at 1:47 PM, Robert Cerny <[email protected]>wrote:
> Michael Wallner wrote:
>
>>
>> On Dec 14, 2013 7:45 AM, "Robert Cerny" wrote:
>> [...]
>>
>>
>> >> When a PHP code base is growing over time it looks more and more
>> 'diverse', because of inconsistent function and method naming in core PHP
>> and third party libraries. This cannot be changed by any guidelines. The
>> author of a function has the freedom to assign any name. The user of a
>> function needs some flexibility in referring to a function. It should be
>> possible to use 'array_key_exists', 'arrayKeyExists' or
>> 'arraykeyExists'.
>> Because of the performance impact and possible resolution conflicts this
>> language feature needs to be disabled by default.
>>
>> Oh, I think this is not the best example, but in 5.6 you can achieve that
>> with the new 'use function' feature.
>>
>> That is not what i mean. My proposal reaches much further. In the
> meantime, i realized how to do it with minimal performance impact. Upon
> parsing, PHP would need to add synonyms for function and method names to
> the namespace depending on the configured referral styles. By 'namespace' i
> do not mean a declared PHP namespace in the formal sense. By default no
> referral styles are configured. Users can choose between 'camel case' and
> 'underscore'. In this case there would be no need to normalize function
> names when looking up a symbol. It would be built-in glasses feature, for
> those who know the emacs mode.
>
>
>> > This is not difficult to implement. It is only necessary to normalize
>> function names: remove all but leading underscores and lower case the
>> result. The likelihood of conflict is very small.
>> >
>> > This small change would allow coding teams to create a consistent code
>> base based on 'their' guidelines. Motto: "Have it your way!".
>>
>> No.
>>
>> What is wrong with having a consistent code base all the way, also
> covering legacy code? I consider this a pretty neat language feature.
Consistency doesn't stop at how functions are named; there are enough
functions that have an unintuitive order of function parameters, this isn't
addressed in your proposal.
If it were just the naming you wish to address, I would suggest writing an
extension first and see how that catches on.
>
> Robert
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
--
Tjerk
Thread (14 messages)