From: Peter Seibel
Subject: When is a restart's :test-function used?
Date: 
Message-ID: <m3zn6z9fjs.fsf@javamonkey.com>
Is COMPUTE-RESTARTS (and thus FIND-RESTART), supposed to use the
:test-functions of the currently bound restarts to determine whether
they should be included in the result? That is if I have these three
functions:

  (defun foo ()
    (restart-bind ((bail #'(lambda () 'foo))) (bar)))

  (defun bar ()
    (restart-bind ((bail #'(lambda () 'bar)
                   :test-function #'(lambda (c) nil)))
      (baz)))

  (defun baz ()
    (format t "~{~s~%~}" (compute-restarts)))

Should invoking FOO return a list containg both BAIL restarts or just
one? Allegro returns just one while OpenMCL returns both. Should that
be considered a bug in OpenMCL? And if so, is there somewhere in the
standard that links COMPUTE-RESTARTS with the restarts'
:test-function?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: Peter Seibel
Subject: Re: When is a restart's :test-function used?
Date: 
Message-ID: <m3vfhmam80.fsf@javamonkey.com>
Peter Seibel <·····@javamonkey.com> writes:

> Is COMPUTE-RESTARTS (and thus FIND-RESTART), supposed to use the
> :test-functions of the currently bound restarts to determine whether
> they should be included in the result? That is if I have these three
> functions:
>
>   (defun foo ()
>     (restart-bind ((bail #'(lambda () 'foo))) (bar)))
>
>   (defun bar ()
>     (restart-bind ((bail #'(lambda () 'bar)
>                    :test-function #'(lambda (c) nil)))
>       (baz)))
>
>   (defun baz ()
>     (format t "~{~s~%~}" (compute-restarts)))
>
> Should invoking FOO return a list containg both BAIL restarts or just
> one? Allegro returns just one while OpenMCL returns both. Should that
> be considered a bug in OpenMCL? And if so, is there somewhere in the
> standard that links COMPUTE-RESTARTS with the restarts'
> :test-function?

Okay, another data point--OpenMCL seems to use the :test-function
functions when COMPUTE-RESTARTS is passed a condition object.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Aurélien Campéas
Subject: Re: When is a restart's :test-function used?
Date: 
Message-ID: <pan.2004.06.20.13.01.26.863569@wanadoo.fr>
sbcl returns one bail restart :

#<RESTART BAIL {9B45DF9}>
#<RESTART ABORT {9B45A19}>
#<RESTART SB-THREAD:DESTROY-THREAD {9AC6021}>
From: Aurélien Campéas
Subject: Re: When is a restart's :test-function used?
Date: 
Message-ID: <pan.2004.06.20.13.38.54.672349@wanadoo.fr>
Le Sun, 20 Jun 2004 01:37:13 +0000, Peter Seibel a �crit�:

> Is COMPUTE-RESTARTS (and thus FIND-RESTART), supposed to use the
> :test-functions of the currently bound restarts to determine whether
> they should be included in the result?

:test-function

    Value is evaluated in the current lexical environment and should
    return a function of one argument, a condition, which returns true if
    the restart is to be considered visible.


hmmm, ok, why did they say "... of one argument, a condition, ..." and
then link condition to its definition in the glossary ? condition must
have been meant in an informal manner, there ...

> 
>   (defun bar ()
>     (restart-bind ((bail #'(lambda () 'bar)
>                    :test-function #'(lambda (c) nil)))
>       (baz)))
> 
> 
> Should invoking FOO return a list containg both BAIL restarts or just
> one? 


 compute-restarts returns all applicable restarts

The same for find-restart :

 If identifier is a symbol, then the innermost (most recently established)
 applicable restart with that name is returned. nil is returned if no such
 restart is found.

Glossary :

applicable restart n. 1. (for a condition) an active handler for which the
associated test returns true when given the condition as an argument. 2.
(for no particular condition) an active handler for which the associated
test returns true when given nil as an argument.


Allegro returns just one while OpenMCL returns both. Should that
> be considered a bug in OpenMCL? And if so, is there somewhere in the
> standard that links COMPUTE-RESTARTS with the restarts'
> :test-function?

Those snippets don't ? 'Applicable restarts' is the key ...

Aur�lien.
From: Aurélien Campéas
Subject: Re: When is a restart's :test-function used?
Date: 
Message-ID: <pan.2004.06.20.13.46.16.997464@wanadoo.fr>
Le Sun, 20 Jun 2004 15:38:55 +0200, Aur�lien Camp�as a �crit�:

> Le Sun, 20 Jun 2004 01:37:13 +0000, Peter Seibel a �crit�:
> 
>> Is COMPUTE-RESTARTS (and thus FIND-RESTART), supposed to use the
>> :test-functions of the currently bound restarts to determine whether
>> they should be included in the result?
> 
> :test-function
> 
>     Value is evaluated in the current lexical environment and should
>     return a function of one argument, a condition, which returns true if
>     the restart is to be considered visible.
> 
> 
> hmmm, ok, why did they say "... of one argument, a condition, ..." and
> then link condition to its definition in the glossary ? condition must
> have been meant in an informal manner, there ...

**gasp** (I don't drink coffee on sundays...)
off course it's meant as the type of the function's argument ...

> applicable restart n. 1. (for a condition) an active handler for which the
> associated test returns true when given the condition as an argument. 2.
> (for no particular condition) an active handler for which the associated
> test returns true when given nil as an argument.
> 
>  
> Those snippets don't ? 

I just hope it helps a bit. Patterns of usage are another matter.
From: Peter Seibel
Subject: Re: When is a restart's :test-function used?
Date: 
Message-ID: <m3y8mi6s2d.fsf@javamonkey.com>
Aur�lien Camp�as <···········@wanadoo.fr> writes:

> Glossary :
>
> applicable restart n. 1. (for a condition) an active handler for which the
> associated test returns true when given the condition as an argument. 2.
> (for no particular condition) an active handler for which the associated
> test returns true when given nil as an argument.

Ah, that's the bit I was missing. So it seems that Allegro is right
and OpenMCL is wrong in the case where COMPUTE-RESTARTS is called with
no argument (i.e. "no particular condition") since my test function
always returns nil. Thanks.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp