home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / scheme / 2167 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.8 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!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: <1992Sep8.162208.13486@sharebase.com>
  6. Date: 8 Sep 92 16:22:08 GMT
  7. References: <1187.9208311520@subnode.aiai.ed.ac.uk> <17timvINN7b8@agate.berkeley.edu> <1992Sep5.075445.26848@greco-prog.fr>
  8. Reply-To: dyer@eagle.sharebase.com (Scot Dyer)
  9. Organization: NCR/ShareBase Corporation
  10. Lines: 46
  11. Nntp-Posting-Host: eagle
  12.  
  13. %[...]bh@anarres.CS.Berkeley.EDU (Brian
  14. %Harvey) writes:
  15. %|> P.S.  Yes of course if an error happens inside a procedure you should be
  16. %|> told its name.  My example was too simple, I guess.  What Logo does on
  17. %|> an error is tell you the error, the procedure in which it happened, and
  18. %|> the line of the procedure definition that contains the error.
  19. %
  20. %The problem in Scheme, as I use it, is that it is not a very interesting
  21. %information as I use a lot of continuation passing style and what I
  22. %call "next function passing style" (as expanders in EPS) so I have a
  23. %lot of anonymous functions, and a lot closure coming from the same
  24. %lambda expression.
  25.  
  26. This is a situation where treating errors as _values_ (like everything else
  27. in scheme) would be terribly useful.  As errors cascaded as the result of
  28. feeding unanticipated error values into functions, a complete backtrace would
  29. be generated.
  30.  
  31. I like this idea because it is consistant with the rest of scheme.  Rather than
  32. inventing a whole new set of functions to handle special flow of control on
  33. exceptions and giving ourselves some big headache by insisting on non-local
  34. control constructs, I like schemes lexical style.  I'd never go back to old
  35. dynamically scoped lisp.
  36.  
  37. And it can be implemented just as easily with anonymous functions...  The key
  38. is to imbed the error message in the error value, along with other 'irritants'
  39. (including error values that might have caused this...), ergo:
  40.  
  41.     (if (car '()) 1 0)
  42. --> #{ERROR: |if condition must be defined.  it was:|
  43.     #{ERROR: |car can't be taken from| #!null}}
  44.  
  45. Just provide (error->list), (list->error), (error?), and the utility 'error'
  46. such that: (define error (lambda l (list->error l)))
  47.  
  48.     -- Scot
  49. +------------------------+-----------------------------------------------+
  50. |Scot Dyer_Rivenburgh    | "Land of song," said the warrior bard,     |
  51. |dyer@eagle.sharebase.com| "Though all the world betrays thee,         |
  52. +------------------------+  One sword, at least, thy rights shall guard, |
  53. |(He's right, you know.) |  One faithful harp shall praise thee."     |
  54. +------------------------+-----------------------------------------------+
  55.  
  56. P.S.  Perhaps calling errors 'undefined' values would be less threatening to
  57. students and no more irritating to seasoned schemers than the errors
  58. themselves?
  59.