The resignal-bind Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The resignal-bind Reference Manual

This is the resignal-bind Reference Manual, version 0.1.3, generated automatically by Declt version 3.0 "Montgomery Scott" on Fri Jun 26 12:07:52 2020 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

RESIGNAL-BIND 0.0.7

Current lisp world

Condition system is very strong.

Issues

Although error message is not user friendly.

Proposal

resignal-bind captures condition in order to make more better error message.

Usage

;; 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


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 resignal-bind

Author

Shinichi Sato

License

MIT

Description

Tiny signal capturing facility.

Long Description

# RESIGNAL-BIND 0.0.7

### Current lisp world
Condition system is very strong.

### Issues
Although error message is not user friendly.

### Proposal
resignal-bind captures condition in order to make more better error message.

## 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
* CCL/1.11.5
* SBCL/2.0.0
* ECL/16.1.3
* CLISP/2.49

Version

0.1.3

Dependency

closer-mop

Source

resignal-bind.asd (file)

Component

resignal-bind.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

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


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 resignal-bind.asd

Location

resignal-bind.asd

Systems

resignal-bind (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 resignal-bind/resignal-bind.lisp

Parent

resignal-bind (system)

Location

resignal-bind.lisp

Packages

resignal-bind

Exported Definitions

resignal-bind (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 resignal-bind

Source

resignal-bind.lisp (file)

Use List

common-lisp

Exported Definitions

resignal-bind (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

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)
(princ c)))
:outputs "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)) :invokes-debugger warning
, :ignore-signals
“‘
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)
(princ c)))
:outputs "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)
(princ c)))
:outputs "1-2"
“‘
in this case, format-control is inherited.
But format-arguments is superseded.

Package

resignal-bind

Source

resignal-bind.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: bind-form BIND TAG VAR
Package

resignal-bind

Source

resignal-bind.lisp (file)

Function: check-error CONDITION
Package

resignal-bind

Source

resignal-bind.lisp (file)

Function: inherit-condition CONDITION TOBE &rest ARGS
Package

resignal-bind

Source

resignal-bind.lisp (file)

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 (file)

Function: slot-status INSTANCE
Package

resignal-bind

Source

resignal-bind.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Conditions

Condition: unknown-condition ()
Package

resignal-bind

Source

resignal-bind.lisp (file)

Direct superclasses
  • type-error (condition)
  • program-error (condition)

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   R  
Index Entry  Section

F
File, Lisp, resignal-bind.asd: The resignal-bind․asd file
File, Lisp, resignal-bind/resignal-bind.lisp: The resignal-bind/resignal-bind․lisp file

L
Lisp File, resignal-bind.asd: The resignal-bind․asd file
Lisp File, resignal-bind/resignal-bind.lisp: The resignal-bind/resignal-bind․lisp file

R
resignal-bind.asd: The resignal-bind․asd file
resignal-bind/resignal-bind.lisp: The resignal-bind/resignal-bind․lisp file

Jump to:   F   L   R  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   B   C   F   I   M   P   R   S  
Index Entry  Section

B
bind-form: Internal functions

C
check-error: Internal functions

F
Function, bind-form: Internal functions
Function, check-error: Internal functions
Function, inherit-condition: Internal functions
Function, pprint-resignal-bind: Internal functions
Function, slot-status: Internal functions

I
inherit-condition: Internal functions

M
Macro, resignal-bind: Exported macros

P
pprint-resignal-bind: Internal functions

R
resignal-bind: Exported macros

S
slot-status: Internal functions

Jump to:   B   C   F   I   M   P   R   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   R   S   U  
Index Entry  Section

C
Condition, unknown-condition: Internal conditions

P
Package, resignal-bind: The resignal-bind package

R
resignal-bind: The resignal-bind system
resignal-bind: The resignal-bind package

S
System, resignal-bind: The resignal-bind system

U
unknown-condition: Internal conditions

Jump to:   C   P   R   S   U