[iterate-devel] handler-bind macroexpansion and special operators (fwd)

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Thu Jan 13 14:06:43 UTC 2005


Hi,

I believe Tayssir John Gabbour's message (included below) reveals
a) a bug in clisp,
b) a general weakness of portable code walking, failing to handle macros that expand to implementation-specific special operators.

For ease of using CC, I send it to clisp-list instead of opening a bugtracker issue.

I believe the cause of the bug is that CLISP fails here to respect the obligation AFAIK (where was that in CLHS?) to have all its macros expand into either functions, macros or special forms -- so that code walkers work in CL.

However, sys::%handler-bind looks like it must be handled as a special form (or macro) from the expansion example appended below, yet it's not declared as such.
[28]> (special-operator-p 'sys::%handler-bind)
NIL

That could probably be easy to fix in CLISP. Iterate would then issue a warning instead of an error: "the CL implementation says that sys::%handler-bind is a special operator, but Iterate does not know how to handle that. It will not be walked, which means that Iterate clauses inside it will not be seen."
-- Better, but still not ideal. How to improve on this?

I don't see how to improve on this situation without adding to Iterate specific code for handler-bind. And potentially many other macros could expand to implementation-specific special forms (really?).

Code-walking really appears tough -- Portable code walking next to impossible?
Sigh

(macroexpand-1'(ignore-errors))
(BLOCK #:G3533
 (HANDLER-BIND
  ((ERROR
    #'(LAMBDA (CONDITION) (RETURN-FROM #:G3533 (VALUES NIL CONDITION))))))) ;
T

(macroexpand-1 (third (macroexpand-1'(ignore-errors))))
(LET
 ((#:G3535
   #'(LAMBDA NIL
      (PROGN
       #'(LAMBDA (CONDITION) (RETURN-FROM #:G3534 (VALUES NIL CONDITION))))))
  (#:G3536 #'(LAMBDA NIL (PROGN))))
 (LOCALLY (DECLARE (COMPILE))
  (SYSTEM::%HANDLER-BIND
   ((ERROR #'(LAMBDA (CONDITION) (FUNCALL (FUNCALL #:G3535) CONDITION))))
   (FUNCALL #:G3536)))) ;
T

Regards,
	Jorg Hohle

>-----Ursprungliche Nachricht-----
>Von:  Tayssir John Gabbour
>Betreff: [iterate-devel] Bug report: handler-bind in FOR
>
>Hi all,
>
>On clisp-2.33.1/win2k, Iterate doesn't like handler-bind. I 
>don't know what the
>issue is; it seems to work in Lispworks, since it was able to compile
>cl-typesetting.
>
>Incidentally, I can't find the link to the mailing list, so 
>please cc: any
>responses to me. ;)
>
>
>;; doesn't work
>(iterate:iter (for x = (ignore-errors 3))
>              (format t "~&blah: ~S" x)
>              (until (= x 3)))
>
>;; works
>(iterate:iter (for x = 3)
>              (format t "~&blah: ~S" x)
>              (until (= x 3)))
>
>
>Error message:
>
>Iterate, in (let nil (declare (compile))
> (%handler-bind
>  ((error #'(lambda (condition) (funcall (funcall g5133) condition))))
>  (funcall g5134))):
>The form ((error #'(lambda (condition) (funcall (funcall 
>g5133) condition))))
>is not a valid Lisp expression
>   [Condition of type simple-error]
>
>MfG,
>Tayssir



More information about the iterate-devel mailing list