Re: pi seems not to be a constant

[email protected] (Don Cohen)
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
Pascal J. Bourguignon writes:

 > It seems to me that (typep cl:pi 'long-float)
 > is more important to maintain than (constantp 'cl:pi).

If you leave pi with its original value this remains true:
(defconstant pi2 pi)
(setf (ext:long-float-digits) 128)
(typep pi2 'long-float) => T 

 > Either case would introduce a small non-conformity of clisp.
 > 
 > The only way we could restore conformity would be to keep long-float 
 > fixed size (and therefore the value of cl:pi identical), and to rename 
 > extended long floats  ext:variable-precision-long-float (or something 
 > else) and have that distinct ext:pi variable.
I think the previous argument was that conformity requires pi to be
the best available approximation, which would require the highest
possible precision, which I don't think anyone wants to do.
So we have to reinterpret that as the best available without using
the extension that changes the amount of precision.

 > a conforming library would work correctly when 
 > processing an expression containing cl:pi with constantp returning NIL 
 > (and therefore, not "inlining" cl:pi,
That's not the only use of constantp.
Don't you think a conforming library might count on constantp to tell 
it what symbols not to accept as variables to be bound?  And if pi
were allowed to be bound, say, to some non-number, don't you think 
some sort of non-conforming behavior might result?

 > Therefore in my opinion, it's better to have constantp return nil for a 
 > non-constant cl:pi, since while it's nominaly non-conforming, allows 
 > more conforming programs to continue working correctly, and since it's 
 > much less complex than adding a fifth float subtype.

I don't see why any such additional subtype is needed.

Perhaps I'm missing something.  Other than recomputing a lot of
constants that I don't think should be changed, what does setting
ext:long-float-digits do?  My impression was that it affected the
result of READing a long float.  Once the value is read, its precision
is fixed, right?  Changing long-float-digits doesn't affect it.

So continuing my previous example, now that we have 64 bit pi2 and
128 bit pi, I get
 (+ 1 pi) => 4.14159265358979323846264338327950288418L0 
 (+ 1 pi2) => 4.1415926535897932383L0 
You might view these as values of two different subtypes of
long-float, namely 64-bit and 128-bit long floats, but type-of
returns long-float in both cases.

------------------------------------------------------------------------------
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.