GMP function naming

Torbjorn Granlund tg at gmplib.org
Sun Oct 18 12:32:09 CEST 2009


nisse at lysator.liu.se (Niels Möller) writes:
  
  Naming is generally poor.

That's a very broad statement!  :-)

It is getting more and more difficult to name the more specialised
functions we're defining.  And for work-in-progress, naming is of course
pretty irrelevant.  Let me anyway take this opportunity to suggest a
naming scheme:

In mpn_alg_operation_operanddesc, let operation define the basic
operation and operanddesc define the operands.  For internal mpn
functions, alg describes the algorithm.

"operation" might be div, bdiv, mul, mullo, mulhi, gcd, gcdext, etc.

The operanddesc part should define which operands are input and output,
but only when a distinction is needed, or if it improves naming
orthogonality.

The alg part should be things like schoolbook (abbreviated sb) not
"basecase" since that is not an algorithm but intended usage.  Why?
E.g., we're likely to have multiple "basecase" division algorithms at
some point, one using the schoolbook algorithm with a single-limb
inverse, one using the schoolbook algorithm with a two-limb inverse, and
one using mullo/mulhi.

Older mpn functions do not adhere to this naming scheme.  We might
change that except when it breaks documented interfaces.

Opinions?

-- 
Torbjörn


More information about the gmp-devel mailing list