• condition restarts : restart-case with :test typep not visible in many lisps

    From Madhu@enometh@meer.net to comp.lang.lisp on Mon Jun 15 12:42:19 2026
    From Newsgroup: comp.lang.lisp

    I think I;ve posted about this on cll many time for the last 2 decades,
    but I still get bitten by this. This is the test case:

    CLHS restart-case

    ```
    :test
    The value supplied by :test value must be a suitable argument to function. (function value) is evaluated in the current lexical environment. It should return a function of one argument, the condition, that returns true if the restart is to be considered visible.
    The default for this option is equivalent to (lambda (c) (declare (ignore c)) t).
    ```

    ```
    (define-condition my-error (error) ())
    (defun my-error-p (thing) (typep thing 'my-error))
    (assert (my-error-p (make-condition 'my-error)))
    (defun test ()
    (block nil
    (restart-case (error 'my-error)
    (ignore-my-error ()
    :report "Ignore My error"
    :test my-error-p
    (return 'ok)))))

    (test)
    ```

    this should drop you in the debugger, you should choose the
    ignore-my-error restart, and that should return 'ok.

    However this only works this way in lispworks, ccl, and sbcl. In all
    other lisps (ecl, clisp, mkcl, cmucl) you get a "restart is not active"
    error. (well cmucl works without sly)

    Is there any excuse by which the lisp can claim the restart is not
    active in this situation?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Jason Cornez@jcornez@dev268-k.mail-host-address-is-not-set to comp.lang.lisp on Mon Jun 29 09:17:09 2026
    From Newsgroup: comp.lang.lisp

    Hi Madhu,

    I don't think I have an answer to your question, but I can report what
    ACL11 does.
    ```
    CL-USER(09:12:12): (define-condition my-error (error) ())
    (defun my-error-p (thing) (typep thing 'my-error))
    (assert (my-error-p (make-condition 'my-error)))
    (defun test ()
    (block nil
    (restart-case (error 'my-error)
    (ignore-my-error ()
    :report "Ignore My error"
    :test my-error-p
    (return 'ok)))))

    (test)

    MY-ERROR
    CL-USER(09:12:16): MY-ERROR-P
    CL-USER(09:12:16): NIL
    CL-USER(09:12:16): TEST
    CL-USER(09:12:16): CL-USER(09:12:16): [2026-06-29 09:12:16]
    Error: #<MY-ERROR @ #x1056e16e072>
    [condition type: MY-ERROR]

    Restart actions (select using :continue):
    0: Return to Top Level (an "abort" restart).
    1: Abort entirely from this (lisp) process.
    [1] CL-USER(09:12:16): :cont 0
    CL-USER(09:12:41):
    ```
    I also confirm the same behavior when the code is in a file and compiled
    before running (test)

    -Jason
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Wed Jul 1 14:19:46 2026
    From Newsgroup: comp.lang.lisp

    * Jason Cornez <87pl19olxm.fsf@dev268-k.mail-host-address-is-not-set> :
    Wrote on Mon, 29 Jun 2026 09:17:09 +0200:
    I don't think I have an answer to your question, but I can report what
    ACL11 does.
    ```
    CL-USER(09:12:12): (define-condition my-error (error) ())
    (defun my-error-p (thing) (typep thing 'my-error))
    (assert (my-error-p (make-condition 'my-error)))
    (defun test ()
    (block nil
    (restart-case (error 'my-error)
    (ignore-my-error ()
    :report "Ignore My error"
    :test my-error-p
    (return 'ok)))))

    (test)

    MY-ERROR
    CL-USER(09:12:16): MY-ERROR-P
    CL-USER(09:12:16): NIL
    CL-USER(09:12:16): TEST
    CL-USER(09:12:16): CL-USER(09:12:16): [2026-06-29 09:12:16]
    Error: #<MY-ERROR @ #x1056e16e072>
    [condition type: MY-ERROR]

    Restart actions (select using :continue):
    0: Return to Top Level (an "abort" restart).
    1: Abort entirely from this (lisp) process.
    [1] CL-USER(09:12:16): :cont 0
    CL-USER(09:12:41):
    ```
    I also confirm the same behavior when the code is in a file and compiled
    before running (test)

    Thanks, yes acl's repl decides the restart isn't visible, and avoids the
    issue. But when running through sly or slime's debuggers, the ignore-my-restart is visible, but when you try to invoke it one gets a
    "restart is not active", like in the other lisps.

    This is a problem when this pattern (of declaring type visibility) is
    used the wild (e.g. with iolib: src/sockets/socket-methods.lisp, where
    the retry-syscall restart is meant to be invoked (say on EAGAIN), but is
    not visible, or if visible, cannot be successfully invoked.)

    [I thought I had a different memory from acl81_express from 2007-2009, I
    didn't have the distribution tar.bz2 but had a backup of an installed
    directory from around then and tried spinning it up under a faketime'd
    qemu with a 32bit system from that time, but i couldn't get past the
    license checks. (in general allegro express licenses expire too
    quickly)
    --- Synchronet 3.22a-Linux NewsLink 1.2