Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Fw: Motion 31 Suggestions - constants



On 2012-02-08 14:59:37 -0500, Ian McIntosh wrote:
> VL> The way I see the P1788 text is that constants are regarded as
> VL> functions for the spec, but it is up to the language to decide
> VL> how they are handled.
> 
> Yes, 1788 can defined constants as functions and languages can
> define them as not functions.
> 
> I spend my time dealing with programs, programming languages and their
> implementation, not with mathematics.  I find treating constants as
> functions counterintuitive and think it introduces unneeded complexity to
> the standard, since every place it mentions functions we have to think
> about whether that part of the wording is exactly correct for constants.

I don't have a clear idea on the subject, but for instance, in MPFR
constants such as pi or log(2) (there are no exported literals) are
necessarily implemented as functions because the result depends on
the precision.

> For example, while an implementation can have a library that includes all
> non-constant functions defined by the standard, it cannot realistically
> have a library that includes all  2^128-1 constants (assuming binary128).
> It makes more sense to me to treat constants differently from functions.
> We do in real life.

There are two meanings for "library": the library in a specification
(like here), and a library of implemented functions on some platform.
As a specification (rather than implementation), a library including
2^128-1 constants is not a problem. But constants (just like functions
in general) don't need to be implemented by a library. For instance,
a compiler can evaluate a constant (e.g. conversion from a string
expressing the constant in decimal) or transform a simple function
call by one or several processor instructions, or evaluate a function
when its argument is a constant.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)