home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / scheme / 2133 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  3.3 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!data.nas.nasa.gov!taligent!apple!voder!woodstock!news
  2. From: dyer@eagle.sharebase.com (Scot Dyer)
  3. Newsgroups: comp.lang.scheme
  4. Subject: Re: wots going on here!?
  5. Message-ID: <1992Sep1.160256.25131@sharebase.com>
  6. Date: 1 Sep 92 16:02:56 GMT
  7. References: <JINX.92Aug29101908@chamarti.ai.mit.edu> <17o70sINNi2e@agate.berkeley.edu> <JINX.92Aug29223329@chamarti.ai.mit.edu> <17piphINNncj@agate.berkeley.edu>
  8. Reply-To: dyer@eagle.sharebase.com (Scot Dyer)
  9. Organization: NCR/ShareBase Corporation
  10. Lines: 66
  11. Nntp-Posting-Host: eagle
  12.  
  13. bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
  14. %%jinx@zurich.ai.mit.edu writes:
  15. %%>There is a large tension in a system
  16. %%>aimed both at experienced users and stark novices between being overly
  17. %%>verbose and "nice" and being useful.
  18. [...]
  19.  
  20. I have to agree here, but I think there's a larger underlying problem.
  21.  
  22. bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
  23. %%The behavior I want would be *less* verbose:
  24. %%        > (+ 2 a)
  25. %%        Unbound variable: a
  26. %%        >
  27. %%Short and sweet.  It should be possible for an advanced user to ask
  28. %%for pause-on-error behavior in which Scheme would attempt to preserve
  29. %%the environment in which the error occurred, but you should have to
  30. %%ask for it.
  31.  
  32. This can be a problem if the 'error' wasn't really an error, but should have
  33. been a warning, because control is taken from the program.  One could
  34. conceivably take this as far as CLOS restarts, and provide a complex procedure
  35. for handling exceptions, involving lots of non-local control structures.
  36.  
  37. I happen to think there's a better way to do exception handling, which isn't
  38. taken up by most languages*.  Imagine if an error were a value, a printable
  39. value like everything else in Scheme [except environments, of course :-)], so
  40. that you'd have something that'd work like:
  41.  
  42.     (define (car some-list)
  43.            (if (null? some-list)
  44.               (error "car of null")
  45.           (lower-level-car some-list)))
  46.  
  47. Where (error "car of null") would produce an error vector, containing the
  48. complaint.  Beyond this, correct behavior is simple.  Each error contains
  49. _irritants_, like a string to explain the error, and it should be an error
  50. say to try to add to an error value, ergo:
  51.  
  52.     #(error "+ on error value" #(error "car of null list"))
  53.     ;;; other printing names may be more sensible...
  54.  
  55. So that a failing program then provides a detailed 'back-trace.'
  56.  
  57. THE BENEFIT:
  58.     (if (error? (car l))
  59.         ...
  60.         ...)
  61.  
  62. bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
  63. %%(This is how Logo does things.  Errors give a message
  64. %%and return to toplevel, unless you have asked in advance for pause
  65. %%on error.  In that case you get a special prompt and (because of good
  66. %%old dynamic scope -- but that's another argument) *all* of the possibly
  67. %%relevant variables are immediately accessible in the usual way without
  68. %%you having to know anything about environments.)
  69.  
  70. This sounds like a nice environment to work in, but I think seeing the actual
  71. _error_ might be more instructive, powerful, flexible, etc.  It also happens
  72. to be more _functional_, but by that I mean no more than that it is extremely
  73. clean.
  74.  
  75.     -- Scot
  76. -------------------------------------------------------------------------------
  77. * Error values are probably not much in use since a staticly typed language
  78.   wouldn't be able to deal with them very well...
  79.