PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/srfi-error-reporting.texi

http://github.com/marcomaggi/vicare
Unknown | 171 lines | 131 code | 40 blank | 0 comment | 0 complexity | 1b7bb3b718e1e043977951ed65bf73d9 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0
  1. @node srfi error-reporting
  2. @section @ansrfi{23} error reporting mechanism
  3. @cindex @ansrfi{23} error reporting mechanism
  4. @cindex @library{srfi :23}, library
  5. @cindex @library{srfi :23 error}, library
  6. @cindex Library @library{srfi :23}
  7. @cindex Library @library{srfi :23 error}
  8. The library @library{srfi :23} is by Stephan Houben as the reference
  9. implementation for @ansrfi{23}; see:
  10. @center @url{http://srfi.schemers.org/srfi-23/srfi-23.html}
  11. @noindent
  12. for more details.
  13. @menu
  14. * srfi error-reporting license:: Error-reporting document
  15. license.
  16. * srfi error-reporting abstract:: Abstract.
  17. * srfi error-reporting rationale:: Rationale.
  18. * srfi error-reporting spec:: Specification.
  19. @end menu
  20. @c page
  21. @node srfi error-reporting license
  22. @subsection Error--reporting document license
  23. Copyright @copyright{} 2001 Stephan Houben @email{stephanh@@win.tue.nl}.
  24. All Rights Reserved.
  25. Permission is hereby granted, free of charge, to any person obtaining a
  26. copy of this software and associated documentation files (the
  27. ``Software''), to deal in the Software without restriction, including
  28. without limitation the rights to use, copy, modify, merge, publish,
  29. distribute, sublicense, and/or sell copies of the Software, and to
  30. permit persons to whom the Software is furnished to do so, subject to
  31. the following conditions:
  32. The above copyright notice and this permission notice shall be included
  33. in all copies or substantial portions of the Software.
  34. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
  35. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  36. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  37. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  38. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  39. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  40. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  41. @c page
  42. @node srfi error-reporting abstract
  43. @subsection Abstract
  44. A mechanism is proposed to allow Scheme code to report errors and abort
  45. execution. The proposed mechanism is already implemented in several
  46. Scheme systems and can be implemented, albeit imperfectly, in any
  47. @rnrs{5} conforming Scheme.
  48. @c page
  49. @node srfi error-reporting rationale
  50. @subsection Rationale
  51. @rnrs{5} Scheme requires certain operations to signal an error when they
  52. fail. ``Signalling an error'' means that implementations must detect
  53. and report the error. Moreover, @rnrs{5} encourages, but not requires,
  54. implementations to signal an error in many more circumstances.
  55. However, there is no direct way for the Scheme application programmer to
  56. report an error that occured in his or her own application. This means
  57. that Scheme procedures created by applications or libraries are in this
  58. respect not on equal footing with procedures provided by the Scheme
  59. system.
  60. Many Scheme systems already provide a mechanism that allows application
  61. code to report an error. At least the following implementations support
  62. such a mechanism: Bigloo, Guile, @acronym{MIT} Scheme, @acronym{PLT}
  63. Scheme, RScheme, Scsh, SCM, all implementations supported by Slib. Of
  64. these implementations, the following have an error mechanism compatible
  65. with this @srfi{}: Guile, @acronym{MIT} Scheme, @acronym{PLT} Scheme,
  66. RScheme, Scsh. The implementation in Slib has a different name than the
  67. one proposed in this @srfi{}.
  68. To summarise, many implementations already have the error reporting
  69. mechanism described in this @srfi{} and others are easily made
  70. compatible with this @srfi{}. This shows that the proposed mechanism
  71. is considered useful and that it is easy to implement in most major
  72. implementations.
  73. @c page
  74. @node srfi error-reporting spec
  75. @subsection Specification
  76. @defun error @var{reason} [@var{arg1} [@var{arg2} ...]])
  77. The argument @var{reason} should be a string. The procedure error will
  78. signal an error, as described in @rnrs{5}, and it will report the
  79. message @var{reason} and the objects @var{arg1}, @var{arg2}, ...
  80. What exactly constitutes ``signalling'' and ``reporting'' is not
  81. prescribed, because of the large variation in Scheme systems. So it is
  82. left to the implementor to do something reasonable. To that end, a few
  83. examples of possible behaviour are given.
  84. @enumerate
  85. @item
  86. Display @var{reason} and @var{arg1}... on the screen and terminate the
  87. Scheme program. This might be suitable for a Scheme system implemented
  88. as a batch compiler.
  89. @item
  90. Display @var{reason} and @var{arg1}... on the screen and go back to the
  91. read--evaluate--print loop. This might be suitable for an interactive
  92. implementation.
  93. @item
  94. In the case of a multi--threaded system: terminate the current thread,
  95. but do not terminate the other threads. Possibly make the arguments to
  96. error available to other threads in some way. See the
  97. @func{thread-join!} mechanism in @ansrfi{18} on how this could be done.
  98. @item
  99. Package @var{reason} and @var{arg1}... up into an error object and pass
  100. this error object to an exception handler. The default exception
  101. handler then might do something as described in points 1 to 3.
  102. @item
  103. In the case of a Scheme system that runs completely unattended and that
  104. has no way to notify a human, the only reasonable course of action might
  105. be to do nothing at all. However, this should be considered a last
  106. resort. Clearly, if all implementors would choose this strategy, this
  107. @srfi{} would not be very useful.
  108. @end enumerate
  109. An implementation might report more information than just @var{reason}
  110. and @var{arg1}... For instance, it might report the procedure name in
  111. which the error occured or even print a stack trace. However, this will
  112. require additional support in the Scheme implementation.
  113. @end defun
  114. @c ------------------------------------------------------------
  115. @subsubheading Why error is a procedure
  116. @noindent
  117. It is conceivable to allow error to be a special form, such as a macro,
  118. rather than a procedure. This might make providing information such as
  119. the source code location easier. This possibility has been considered,
  120. but rejected, for two reasons.
  121. @enumerate
  122. @item
  123. Since error accepts a variable number of arguments, it could
  124. occasionally be useful to use apply to call error. However, this is not
  125. possible if error was allowed to be a special form.
  126. @item
  127. Since error is currently a procedure in all Scheme implementations
  128. mentioned above, it doesn't seem all that worthwhile to allow it to be a
  129. special form.
  130. @end enumerate
  131. @c end of file