The resignal-bind Reference Manual

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.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 resignal-bind

Tiny signal capturing facility.

Author

SATO Shinichi

Source Control

(GIT git@github.com:hyotang666/resignal-bind)

Bug Tracker

https://github.com/hyotang666/resignal-bind/issues

License

MIT

Long Description

# 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.

Version

0.2.3

Dependency

closer-mop (system).

Source

resignal-bind.asd.

Child Component

resignal-bind.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 resignal-bind/resignal-bind.asd

Source

resignal-bind.asd.

Parent Component

resignal-bind (system).

ASDF Systems

resignal-bind.


3.1.2 resignal-bind/resignal-bind.lisp

Source

resignal-bind.asd.

Parent Component

resignal-bind (system).

Packages

resignal-bind.

Public Interface

resignal-bind (macro).

Internals

4 Packages

Packages are listed by definition order.


4.1 resignal-bind

Source

resignal-bind.lisp.

Use List

common-lisp.

Public Interface

resignal-bind (macro).

Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: resignal-bind (binds &body body)

# 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)))))
“‘

Package

resignal-bind.

Source

resignal-bind.lisp.


5.2 Internals


5.2.1 Ordinary functions

Function: <handler-def> (bind ?handler var tag)
Package

resignal-bind.

Source

resignal-bind.lisp.

Function: check-error (condition)
Package

resignal-bind.

Source

resignal-bind.lisp.

Function: inherit-condition (condition tobe &rest args)
Package

resignal-bind.

Source

resignal-bind.lisp.

Function: pprint-resignal-bind (stream exp &rest noise)

# 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)"
“‘

Package

resignal-bind.

Source

resignal-bind.lisp.

Function: slot-status (instance)
Package

resignal-bind.

Source

resignal-bind.lisp.


5.2.2 Conditions

Condition: unknown-condition
Package

resignal-bind.

Source

resignal-bind.lisp.

Direct superclasses
  • program-error.
  • type-error.

Appendix A Indexes


A.1 Concepts


A.3 Variables