Re: Resurrecting the Function Renaming Thread

From: Date: Tue, 06 Feb 2001 21:25:23 +0000
Subject: Re: Resurrecting the Function Renaming Thread
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-2237@lists.php.net to get a copy of this message
At 20:13 6.2. 2001, Zak Greant wrote the following: -------------------------------------------------------------- >Jim Winstead wrote: >> on the function naming issue, i would just suggest that maintaining >> consistency with well-known names is a good thing. particular for things >> like the string-handling functions. it is very frustrating to hop between >> languages that have identical functions with slightly different names. Ok Jim, but what do you want to be consistent with? AddCSlashes, or get_cfg_var? bin2hex or bindec? or even strtolower? There are too many rabbits to catch. I would kill for being relieved from having to check the names consistently or just try and see if it works. > Initially, I am most interested in cleaning up problems with naming > in extensions. People may or may not agree with fixing the names > for early/core functions. > >> overall, i think the gain from worrying about this is relatively small. >> i'd rather see effort be put into getting pear up to snuff, and adding >> those language features that will make pear better (ie, namespaces). > > The daily individual gain from having sensible and consistent names > for functions will be relatively small. I disagree. YMMV, but IMO the benefit of a consistent--and followed--naming scheme would be gigantic. It pays off to both novice programmers (be it complete coding virgins or people with coding background). It might be (and often is) to 'hop between languages', especially the similar ones, but the reality is that languages are different. Otherwise there'd be only one programming language. If you program in more than one language, knowing that is_numeric is (must be!) is_numeric and not isnumeric, that is_set is is_set and not isset or isSet etc means you don't have to know the function name exactly. You don't have to keep in your mind 'this is from C, so it'll be the same', 'this reflects that API, so it's like this' or 'this is from another API, so it's completely different'. Function names are (consist of) plain English words and (when they're well-chosen) they (should) not only clearly describe the action the functions perform, but also be obvious, so you can just type what you want without any research and it'll be the function in many cases. The is_numeric function happens to be quite a good example. If PHP really sticked to the underscore convention, one wouldn't probably have to look at the manual to use the function. The name lends itself. You could just think, "well, I bet there's a function for this, and it must be named 'is_numeric', because that's what it does. It could never be named foobar. And there'll be an underscore, because that's what _everything_ looks like in PHP.' And bingo, you'd be right. However, the reality is, than in PHP, you can never be sure if it isn't isnumeric or numeric, so you just have to skim the manual. And when you need to use the function again after two weeks for example, you have to look again (or try it - _try_, not _do_), because you remember that the words are 'is' and 'numeric', but you cannot be sure it there's an underscore between or not. PHP is another language, if it should copy another language, why develop it in the first place? The simpler the grammar, the more literate people. And personally, I find a language with consistently named functions (more) beautiful. > PHP users will have to look at > the manual a few less times per day and may save themselves a > few minutes here and there. In addition, we will avoid a few > mistakes of the isset/is_set kind. I have made that mistake a > number of times. I use isset often enough that I remember that > there is no underscore in the name now. However, there are lots > of functions with similar naming schemes that I don't use often > and still make the mistake with. That's what I'm talking about. > In short, I think that making the core language more consistent > should have higher priority than adding loads of external extra > functionality. I would even prefer fixing bugs. > --zak > > ps - thanks for the feedback Jim! ------end of quote------ Will I be in the credits too? :) (Just joking.) ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz

« previous php.qa (#2237) next »