This is the resignal-bind Reference Manual, version 0.2.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:35:57 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
resignal-bind
Tiny signal capturing facility.
SATO Shinichi
(GIT git@github.com:hyotang666/resignal-bind)
MIT
# RESIGNAL-BIND 0.0.7
## Alternatives and differences
| | [more-conditions] | resignal-bind |
| — | —————– | ————- |
| API | 38 symbols | 1 symbol |
[more-conditions]: https://github.com/scymtym/more-conditions
## Usage
“‘lisp
;; define simple example.
(defun enstrings (list)
(labels ((rec (list &optional acc)
(if (endp list)
(nreverse acc)
(rec (cdr list) (push (princ-to-string (car list)) acc)))))
(rec list)))
=> ENSTRINGS
;; behavior
(enstrings ’(1 2 3))
=> ("1" "2" "3")
;; bad case.
(enstrings ’(1 2 . 3))
=> ERROR
#+clisp *** - ENDP: A proper list must not end with 3
#+ccl > Error: The value 3 is not of the expected type LIST.
#+ecl Condition of type: SIMPLE-TYPE-ERROR
In function ENDP, the value of the only argument is
3
which is not of the expected type LIST
#+sbcl The value 3 is not of type LIST.
;; Error message is not user friendly, because user used enstrings not endp.
;; for example,
(defun enstrings (list)
(labels ((rec (seq &optional acc)
(if (resignal-bind
((error nil ’simple-error
:format-control \"~S: Accepts only proper list, but ~S\"
:format-arguments (list ’enstrings list)))
(endp seq))
(nreverse acc)
(rec (cdr seq) (push (princ-to-string (car seq)) acc)))))
(rec list)))
=> ENSTRINGS
(enstrings ’(1 2 . 3))
=> ERROR
ENSTRINGS: Accepts only proper list, but (1 2 . 3)
;; TIPS! - If you feel resignal-bind in the source code is annoying to read,
;; MACROLET allows you to more pretty source code.
;; e.g.
(macrolet ((! (form)
‘(resignal-bind
((error nil ’simple-error
:format-control \"~S: Accepts only proper list, but ~S\"
:format-arguments (list ’enstrings list)))
,form)))
(defun enstrings (list)
(labels ((rec (seq &optional acc)
(if (! (endp seq))
(nreverse acc)
(rec (cdr seq) (push (princ-to-string (car seq)) acc)))))
(rec list))))
;; Why don’t you use resignal-bind at refactoring stage.
“‘
## From developer
### Product’s goal
Maybe already
### License
MIT
### Tested
* SBCL/2.1.7
* CCL/1.12.1
* CLISP/2.49 ; Failed.
* ECL/16.1.3
* Allegro/10.1
* CMUCL/21D
* ABCL/1.8.0 ; Failed.
### Known issues.
#### CLISP
[CLISP say](https://clisp.sourceforge.io/impnotes.html#clpp)
> The Lisp Pretty Printer implementation is not perfect yet.
Works fine, but S-expression printed as not pretty.
#### ABCL
Works fine, but S-expression printed as not pretty.
0.2.3
closer-mop
(system).
resignal-bind.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
resignal-bind/resignal-bind.lisp
resignal-bind
(system).
resignal-bind
(macro).
<handler-def>
(function).
check-error
(function).
inherit-condition
(function).
pprint-resignal-bind
(function).
slot-status
(function).
unknown-condition
(condition).
Packages are listed by definition order.
resignal-bind
common-lisp
.
resignal-bind
(macro).
<handler-def>
(function).
check-error
(function).
inherit-condition
(function).
pprint-resignal-bind
(function).
slot-status
(function).
unknown-condition
(condition).
Definitions are sorted by export status, category, package, and then by lexicographic order.
# RESIGNAL-BIND
## Description:
capturing condition.
Then resignaling another condition.
“‘lisp
#?(resignal-bind ((error nil ’program-error))
(error ’error))
:signals program-error
“‘
#### NOTE!
Just SIGNALING condition become invoking debugger.
“‘lisp
#?(resignal-bind ((error nil ’program-error))
(signal ’error))
:invokes-debugger program-error
“‘
Purpose is making better error message.
“‘lisp
#?(handler-case
(resignal-bind ((error nil ’simple-error :format-control "foo"))
(error "bar"))
(error (c) c))
:satisfies (lambda (c)
(& (equal (simple-condition-format-control c) "foo")))
“‘
it is invalid that downgrade error to warning,
but upgrade warning to error.
“‘lisp
#?(resignal-bind ((warning nil ’program-error)) (warn ’warning))
:invokes-debugger program-error
“‘
“‘lisp
#?(resignal-bind ((error nil ’warning)) (error ’error))
:signals control-error
“‘
same with CL:HANDLER-BIND, without signaling, nothing to do.
“‘lisp
#?(resignal-bind ((error nil ’simple-error :format-control "why?"))
(+ 1 2))
=> 3
“‘
same with CL:HANDLER-BIND, no binds is valid form.
“‘lisp
#?(resignal-bind () (+ 1 2))
=> 3
“‘
same with CL:HANDLER-BIND, compound type specifier is valid.
“‘lisp
#?(resignal-bind (((not arithmetic-error) () ’program-error))
(/ 1 (parse-integer "0")))
:signals arithmetic-error
, :lazy
“‘
like CL:HANDLER-CASE’s clause,
we can access captured condition when var is specified.
“‘lisp
#?(handler-case
(resignal-bind
((error (c) ’simple-error
:format-control (concatenate ’string
(simple-condition-format-control c)
" added string")))
(error "error"))
(error (c) c))
:satisfies (lambda (condition)
(& (equal (simple-condition-format-control condition)
#.(or #+allegro "~1@<error~:@> added string"
"error added string"))))
“‘
Resignal-bind support status inheritance.
When new condition has same slot with old condition,
such value is inherited unless specified explicitly.
“‘lisp
#?(handler-case
(resignal-bind ((error nil ’simple-error :format-arguments ’(1 2)))
(error "~S-~S" :a :b))
(error (c) c))
:satisfies (lambda (condition)
;; in this case, format-control is inherited.
;; But format-arguments is superseded.
(& (equal "1-2"
(apply #’format nil
(simple-condition-format-control condition)
(simple-condition-format-arguments condition)))))
“‘
# PPRINT-RESIGNAL-BIND
## Description:
### syntax
(PPRINT-RESIGNAL-BIND stream exp &rest noise)
=> result
## Arguments and Values:
stream :=
exp :=
noise :=
result :=
## Affected By:
## Side-Effects:
## Notes:
## Exceptional-Situations:
## Tests:
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind))
:outputs "(RESIGNAL-BIND)"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind nil))
:outputs "(RESIGNAL-BIND ())"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind nil nil))
:outputs "(RESIGNAL-BIND ()
NIL)"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind nil hoge))
:outputs "(RESIGNAL-BIND ()
HOGE)"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind (a)))
:outputs "(RESIGNAL-BIND (A))"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind (nil)))
:outputs "(RESIGNAL-BIND (NIL))"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind ((nil))))
:outputs "(RESIGNAL-BIND ((NIL)))"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(resignal-bind ((a nil))))
:outputs "(RESIGNAL-BIND ((A ())))"
“‘
“‘lisp
#?(pprint-resignal-bind nil ’(RESIGNAL-BIND ((ERROR () ’SIMPLE-ERROR
:FORMAT-CONTROL "Missing initform.~%~S"
:FORMAT-ARGUMENTS(LIST SLOT hoge)))
form))
:outputs "(RESIGNAL-BIND ((ERROR () ’SIMPLE-ERROR
:FORMAT-CONTROL \"Missing initform.~%~S\"
:FORMAT-ARGUMENTS (LIST SLOT HOGE)))
FORM)"
“‘
program-error
.
type-error
.
Jump to: | <
C F I M P R S |
---|
Jump to: | <
C F I M P R S |
---|
Jump to: | C F P R S U |
---|
Jump to: | C F P R S U |
---|