CARVIEW |
Select Language
HTTP/2 200
server: myracloud
date: Sun, 12 Oct 2025 02:32:45 GMT
content-type: text/html; charset=utf-8
content-length: 3286
vary: accept-encoding
content-encoding: gzip
expires: Sun, 12 Oct 2025 02:32:45 GMT
cache-control: max-age=0
etag: "myra-4672df85"
php.internals: Re: Flexible function naming
Re: Flexible function naming
From: Tjerk Meesters Date: Mon, 16 Dec 2013 07:22:13 +0000 Subject: Re: Flexible function naming References: 1 2 3 Groups: php.internals Request: Send a blank email to internals+get-70650@lists.php.net to get a copy of this message
On Mon, Dec 16, 2013 at 1:47 PM, Robert Cerny <robert@cerny-online.com>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: https://www.php.net/unsub.php > > -- -- Tjerk
Thread (14 messages)
« previous | php.internals (#70650) | next » |
---|