home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / lisp / 2067 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.5 KB

  1. Xref: sparky comp.lang.lisp:2067 comp.lang.clos:584
  2. Path: sparky!uunet!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!princeton!siemens!volvo!mlg
  3. From: mlg@siemens.com. (Michael Greenberg)
  4. Newsgroups: comp.lang.lisp,comp.lang.clos
  5. Subject: Beware of print-object methods when debugging
  6. Message-ID: <mlg.711741357@volvo>
  7. Date: 21 Jul 92 17:55:57 GMT
  8. Sender: news@siemens.siemens.com
  9. Followup-To: comp.lang.lisp
  10. Lines: 34
  11.  
  12.  
  13. A coworker came into my office this morning to ask for help debugging
  14. his program.  The bug seemed to be in a part of the program that did
  15. processing nodes in a graph. The code seemed to work correctly for all
  16. objects (about 1000 of them) except for one.
  17.  
  18. Somewhere in the code there was a statement like:
  19.  
  20. (setf (node-a node) (make-instance 'foo ...))
  21.  
  22. We would do something like
  23.  
  24. (dolist (node (all-objects-in-tree))
  25.   (print (node-a node)))
  26.  
  27. and see the expected results except for one object where 'NIL' was
  28. printed.   The code was pretty complex and there were all sorts of
  29. dependencies between the various objects in the system, so it wasn't
  30. surprising that that was an error somewhere.  
  31.  
  32. I beat on this for a while trying to figure out what was
  33. going on.  30 minutes later he said "By the way, I also have a
  34. question about print-object...".
  35.  
  36. It turns out the problem was that his print-object method for the
  37. class 'foo' sometimes printed 'NIL'.
  38.  
  39.  
  40.  
  41. --
  42. Michael Greenberg                      email: mgreenberg@siemens.com
  43. Siemens Corporate Research             phone: 609-734-3347
  44. 755 College Road East
  45. Princeton, NJ 08540
  46.