Comment on PEP-0238

Gareth McCaughan Gareth.McCaughan at pobox.com
Sun Jul 8 14:35:48 EDT 2001


Tim Peters wrote:

> Alternative:  Given the point about dumbdbm above, the missing half is a
> builtin to return (mathematically) ceiling(i/j) too.  A very direct approach
> to both is to forget div/idiv and introduce two-argument builtins
> 
>     floor(i, j)   # return floor of mathematical quotient
>     ceiling(i, j) # return ceiling of mathematical quotient
> 
> instead.  They should also have 1-argument flavors, corresponding to the
> current math.floor and math.ceil.  This would emphasize that the real point
> to all this stuff is computing floors and ceilings, not really about the
> numeric types of division arguments (that's always been a red herring!).

All you have to do now is to add two more similar functions
called "round" and "truncate", and you've rediscovered the
approach taken by Common Lisp. (Except that CL's floor/...
functions return two values, the quotient and the remainder;
but CL takes a different approach to multiple return values
from Python's.)

If I liked Python less than I do, I'd see a sign of Greenspun's
Tenth Rule of Programming at work.

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
.sig under construc



More information about the Python-list mailing list