Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#642 ANSI CL forbids mixed-type complex numbers

pending-invalid
Bruno Haible
clisp (525)
5
2012-05-07
2012-05-07
John Cowan
No

CLHS (under Function COMPLEX) says that the real and imaginary parts of a complex numbers must either be both rational or both of the same float type, and if they are not, floating-point coercion must be done. One of the given examples is (complex 1 .99) => #C(1.0 0.99).

But in CLISP, (integerp (realpart (complex 1 .99)) => #t. This means that the real part is being stored as a rational number, since there is no coercion from floats to rationals. COMPLEX (and #C) should be changed to make sure both parts are either rational or of the same float type.

This bug is present both in 2.48 on Cygwin and 2.44.1 on Ubuntu Lucid (both from binary packages). Here are the clisp --version outputs:

GNU CLISP 2.48 (2009-07-28) (built on ATGRZWN502840.avl01.avlcorp.lan [157.247.26.41])
Software: GNU C 4.3.4 20090804 (release) 1
gcc-4 -O2 -pipe -g -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O2 -fexpensive-optimizations -falign-functions=4 -DUNICODE -DDYNAMIC_FFI -I. -Wl,--stack,8388608 -Wl,--enable-auto-import /usr/lib/libintl.dll.a /usr/lib/libiconv.dll.a /usr/lib/libreadline.dll.a -lncurses /usr/lib/libavcall.a /usr/lib/libcallback.a /usr/lib/libiconv.dll.a -L/usr/lib -lsigsegv
SAFETY=0 HEAPCODES STANDARD_HEAPCODES SPVW_PAGES SPVW_MIXED
libsigsegv 2.8
libiconv 1.13
libreadline 6.0
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI
GETTEXT UNICODE BASE-CHAR=CHARACTER PC386 UNIX CYGWIN)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib/clisp-2.48/
User language: ENGLISH
Machine: I686 (I686) LNGNYCL-FDB00M1.legal.regn.net [192.168.1.118]

GNU CLISP 2.44.1 (2008-02-23) (built 3476024583) (memory 3544628985)
Software: GNU C 4.4.3
i486-linux-gnu-gcc -g -O2 -Igllib -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -O2 -fexpensive-optimizations -falign-functions=4 -DUNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -I. -Wl,-Bsymbolic-functions -x none /usr/lib/libreadline.so -lncurses -ldl /usr/lib/libavcall.so /usr/lib/libcallback.so -L/usr/lib -lsigsegv
SAFETY=0 HEAPCODES LINUX_NOEXEC_HEAPCODES GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.5
libreadline 5.2
Features:
(ASDF CLC-OS-DEBIAN COMMON-LISP-CONTROLLER BERKELEY-DB CLX-ANSI-COMMON-LISP CLX READLINE REGEXP SYSCALLS I18N
LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES
SCREEN FFI GETTEXT UNICODE BASE-CHAR=CHARACTER PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline linux clx bdb)
Installation directory: /usr/lib/clisp-2.44.1/
User language: ENGLISH
Machine: I686 (I686) pubuntu [127.0.0.1]

Discussion

  • Sam Steingold
    Sam Steingold
    2012-05-07

    This bug report is now marked as "pending"/"invalid".
    This means that we think that the problem you report is not a problem with CLISP.
    Unless you - the reporter - act within 2 weeks, the bug will be permanently closed.
    Sorry about the inconvenience - we hope your silence means that you agree that this is not a bug in CLISP.

     
  • Sam Steingold
    Sam Steingold
    2012-05-07

    • status: open --> pending-invalid
     
  • John Cowan
    John Cowan
    2012-05-07

    • status: pending-invalid --> open-invalid
     
  • John Cowan
    John Cowan
    2012-05-07

    I agree that it is documented, but deny that it is a valid ANSI CL extension. Section 1.6 of the CLHS says: "An implementation can have extensions, provided they do not alter the behavior of conforming code and provided they are not explicitly prohibited by this standard." But (integerp (realpart (complex 1 2.0))) is conforming code, and the standard requires that it return NIL due to floating-point contagion. Making it return T instead is altering its behavior, and makes the implementation non-conformant.

    A legitimate way of providing mixed-type complex numbers is to introduce an implementation-dependent function and/or lexical syntax for creating them.

     
  • Sam Steingold
    Sam Steingold
    2012-05-07

    • status: open-invalid --> pending-invalid