Re: pi seems not to be a constant

[email protected] (Don Cohen)
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
 > ;; portable CL code library
 > (defun circle-area (radius)
 >   (* radius radius pi))

Note that your portable code could have also been
  (* radius radius #.pi)
which is supposed to mean the same thing.

In clisp it doesn't, but under my proposal it would.

 > currently in Clisp I can use the above code in this way:
 > (setf (ext:long-float-digits) 1000)
 > ;; print area with 1000 bits precision
 > (print (circle-area 42l0))

Note that you are now asking for your "portable" code to exhibit
non portable behavior.
What you get from clisp under my proposal would be the same as
you'd get from code in other lisps (after the break when you try
to change precision).  That seems more "portable" to me.

In order to get this non portable behavior I think you should
write instead
 (defun circle-area (radius)
   (* radius radius (pi)))
and if you want that to work in other lisp implementations,
#-clisp (defun pi() pi)

 > This will break under your proposal.  I think this is an important
 > use case and I will be unhappy if this stopped working.

The terms "break" and "stop working" seem out of place here.
To me the code seems to be working in the standard and portable
way.  Admittedly that's not what you want.  You want it to work
in some way outside the standard.  I think you should expect to 
write something outside of the standard in order to get that to
happen.  (Even something in addition to setting the precision.)

------------------------------------------------------------------------------
_______________________________________________
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.