Re: pi seems not to be a constant
"Pascal J. Bourguignon" <[email protected]>
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Organization | Informatimago |
| Message-ID | <[email protected]> |
On 19/10/15 23:55, Pierpaolo Bernardi wrote: > On Mon, Oct 19, 2015 at 8:46 PM, Don Cohen > <[email protected]> wrote: >> > Yes, now it is a sound proposal. But, if implemented in plain Clisp it >> > would make variable precision floats a PITA to use, in addition to >> >> I don't see how it makes variable precision any worse than before. > A typical use case for adjustable precision floats is the following: > > (setf (ext:long-float-digits) some-appropriate-number-of-bits) > (large-body-of-standard-portable-cl-code-using-long-floats) > > If long-float-digits is changed and the "constants" are not adjusted > then STANDARD PORTABLE CL code will break. This is incomplete: Not only the constants should be adjusted, but all the standard portable CL code that has been compiled so far needs to be compiled again, because defconstant constants can be inlined. This is to avoid having to recompile and reload everything each time you set ext:long-float-digits, that cl:pi is not a constant. > >> > Still, I don't get the need to do this work, supposing someone is >> > willing to do it (It seems I haven't got all the emails in this thread >> > and I may have missed some clarifying explanation of this point) >> >> I don't claim it's necessary, only an improvement. A small one, but >> also, I think, requiring a small amount of work. > Maybe a simpler solution could be to replace CL:CONSTANTP with > something similar to > > (setf (symbol-function 'cl::system-constantp) (symbol-function 'cl:constantp) > > (defun cl:constantp (x) > (case s > ((CL:PI CL:MOST-POSITIVE-LONG-FLOAT ...) t) > (otherwise (cl::system-constantp x)))) > > when compliance wrt this issue is desired. > > Would this break something? Yes. It would break code that has been compiled before you set long-float-digits, and that would use the old value instead of the new one. On the other hand, if you have long-float literals in the source code, then you would have to re-read this source code too, to take into account the new precision. And it should be noted, that if you keep modifying long-float-digits, you can have in the image, and still use and combine in expressions, long-float values of different precisions. The user shall know what he's doing. But for values like π or e, you definitely want to provide the value in the new (or best) precision. In the case of e, it's simple, since there's no such constant, but a function (exp 1L0). In the case of π, CL:PI is redundant, we could as well use (* 4L0 (atan 1L0)). -- __Pascal J. Bourguignon__ http://www.informatimago.com/ ------------------------------------------------------------------------------ _______________________________________________ clisp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-list