function names again (goals and a questionnaire)
| From: | Cynic | Date: | Wed, 14 Feb 2001 02:21:35 +0000 |
| Subject: | function names again (goals and a questionnaire) | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-2381@lists.php.net to get a copy of this message | ||
I'll try to summarize what we have so far.
I think everybody agrees function names should follow
a pattern, at least those in php/ext/*. PHP has had it
already, though an informal one, and it has been used.
However, it has not been used consistently, and a change
should take place.
There has been even talk about changing the order of
arguments in some functions to gain more consistency. This
would probably mean that such a function couldn't be just
aliased, a new function would have to be created as a wrapper
for the original. (If I'm wrong on this, somebody correct
me.)
However, firtst things first, and here's a list of steps
that could be followed in this effort. The following text
describes the 'maximum' scenario, and is laid from the basic
stuff to the more sensitive things.
The goals:
0.
We need to agree on the extent of the changes. However,
I don't believe this can be achieved by just discussing;
actual work is needed, and I would suggest a permutation of
Apache Group's commit voting: change is made if it gets
certain number of +1's and no -1. The borders will become
visible as we discuss individual functions. IMO the new
stuff should be added to CVS _after_ we agree on the whole
thing - and that means we need to have it finished first.
1.
all extension functions should be named like this:
<ext><underscore><action> e. g. mysql_fetch_array()
2.
the <action> part of function name should be formalized
too
2.1
as per Zeev's suggestion, we don't have to stop at putting an
underscore between the <ext> and <action>. however, a compromise
between the descriptiveness and desirable length needs to be
found.
2.2
things like deg2rad / dechex / strtolower could use some
cleanup too. and if we leave these as they are, we should
agree on something for future functions.
2.3
what about functions like getallheaders()? sticking "apache_"
in front of it isn't what we want, I guess.
3.
the order of arguments would be changed to follow a common
pattern.
As soon as we agree on the extent and the shape of the changes,
guidelines for authors of future enhancements should be written
and placed somewhere so that they're easily accessible. These
guidelines should probably instruct people to consult their
function names here on php-qa and/or on php-dev. They should be
written when and if we finish the 'cleanup', because it's likely
we'll find situations where the theoretical rules we agree on
will be inapplicable. However, the sooner the better, new
extensions appear and the sooner we have it, the less work for
everybody later.
The questionnaire.
Take these examples. What would you prefer? I'll collect your
opinions, so the more replies, the better.
1.
goal #1 goal #2.1(?)
bcadd -> bc_add
bccomp -> bc_comp -> bc_compare
bcdiv -> bc_div -> bc_divide
bcmod -> bc_mod -> bc_modulus
bcmul -> bc_mul -> bc_multiply
bcpow -> bc_pow -> bc_power
bcscale -> bc_scale -> bc_scale
bcsqrt -> bc_sqrt -> bc_square / bc_squareroot / bc_square_root
bcsub -> bc_sub -> bc_subtract
2.
What scheme do you prefer regarding goal 2.2?
deg2rad / dechex / strtolower
3. (goal 2.3)
How would you treat functions like getallheaders()? How would
you alias this particular function should it need an alias?
4.
What's your take on shuffling the order of arguments in the
aliases? Should this happen at all? If so, what do you prefer:
strpos() (strpos(haystack,needle)) or explode() (basically
explode(needle,haystack))?
____________________________________________________________
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