[Ecls-list] Some test grid patches

Peter Salvi salvipeter at gmail.com
Sat Jan 5 18:48:26 UTC 2013


Hi,

After reading the "Involvement in ECL" post, I've looked into some of
the test grid failures. Here is what I found.

1) CL-PPCRE
===========

The test suite fails, because the ~x FORMAT directive gives a
lowercase string in ECL, i.e. (format nil "~x" #xab) => "ab",
while in other implementations (such as ABCL, CCL, CLISP, SBCL) it
gives an uppercase string ("AB" in the example).

This is not limited to FORMAT, but concerns printing in general, e.g.
(let ((*print-base* 24.) (*print-radix* t))
   (print 23.))
>>  #24rn

The HyperSpec (22.3.2, 22.4) does not clarify this ("For radices above
10, letters of the alphabet are used to represent digits above 9."),
but for the above example gives "#24rN", so I believe that's the
intent.

The patch modifies the call to mpz_get_str to use bases -2..-36:
------------------------------------------------------------------------
diff --git a/src/c/printer/integer_to_string.d
b/src/c/printer/integer_to_string.d
index c6e8d87..3b1f526 100644
--- a/src/c/printer/integer_to_string.d
+++ b/src/c/printer/integer_to_string.d
@@ -31,11 +31,11 @@ bignum_to_string(cl_object buffer, cl_object x,
cl_object base)
                /* With the leading sign and the trailing null character,
                 * only 62 digits fit in this buffer. */
                 char txt[64];
-                mpz_get_str(txt, b, x->big.big_num);
+                mpz_get_str(txt, -b, x->big.big_num);
                 _ecl_string_push_c_string(buffer, txt);
         } else {
                 char *txt = ecl_alloc_atomic(str_size + 2);
-                mpz_get_str(txt, b, x->big.big_num);
+                mpz_get_str(txt, -b, x->big.big_num);
                 _ecl_string_push_c_string(buffer, txt);
                 ecl_dealloc(txt);
         }
------------------------------------------------------------------------

2) CL-NUM-UTILS
===============

Loading fails when a method is defined, which does not have one of the
generic function's key arguments. As a simplified example, take:

(defgeneric test (&key my-key &allow-other-keys) (:method (&key) t))

This behavior seems to be correct, even when the generic function has
allow-other-keys, for example, ABCL, CCL, and CLISP all behave the
same, except for SBCL.

HyperSpec (on DEFMETHOD) is somewhat cryptic on this, but it seems
natural to forbid such declarations. I've contacted the author of the
library.

Another problem arises, when a method specializes on FIXNUM, e.g.:

(defgeneric test (a) (:method ((a fixnum)) t))

This is allowed in ABCL, CCL, and SBCL. In CLISP and ECL, however,
FIXNUM is a type, but not a class. I'm sure this is intentional, but a
FIXNUM class would be a nice feature.

As for the tests, they still fail, because LIFT's
GET-BACKTRACE-AS-STRING is not ported to ECL.
Something like this would work:

#+ecl
(defun get-backtrace-as-string (error)
  (declare (ignore error))
  (let ((top (si::ihs-top)))
    (format nil "~{~a: ~a~^~%~}"
            (loop for ihs from top downto 1
               collect (- top ihs)
               collect (si::ihs-fun ihs)))))

I've posted this to lift-devel as well.

3) CLOSER-MOP
=============

In ENSURE-GENERIC-FUNCTION, with (SETF GENERIC-FUNCTION-NAME) as name,
and with CLOS as *PACKAGE*, execution seems to enter
SPECIAL-OPERATOR-P, which should only be called with symbols.

This is because the test
  (si::instancep (fdefinition '(setf generic-function-name)))
returns NIL, as this setter is a function in the CLOS package.

We cannot just change the DEFUN into a DEFMETHOD, since CLOS may not
have booted at this point. We could redefine it later, though:

(defgeneric (setf generic-function-name%) (new-name gf)
  (:method (new-name gf)
    (reinitialize-instance gf :name new-name)))
(setf (fdefinition '(setf generic-function-name))
      (fdefinition '(setf generic-function-name%)))

The only question is where to place the above code...?

That's all for now,

Peter





More information about the ecl-devel mailing list