home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / lisp / 2320 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  3.5 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!cc.helsinki.fi!pirinen
  2. From: pirinen@cc.helsinki.fi
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: style-guide
  5. Keywords: style
  6. Message-ID: <1992Aug28.004913.1@cc.helsinki.fi>
  7. Date: 27 Aug 92 22:49:13 GMT
  8. References: <HALTRAET.92Aug13043710@monsun.si.no>
  9. Sender: news@klaava.Helsinki.FI (Uutis Ankka)
  10. Organization: University of Helsinki
  11. Lines: 63
  12.  
  13. An interesting subject and a good starting point, I guess I must
  14. comment.  (I wrote something yesterday, but I think the machine managed
  15. to lose it while sending, so here we go again:)
  16.  
  17. I think programming style is an aspect of the central skill of a
  18. programmer.  That skill is communication.  Some people like to repeat
  19. Dijkstra's dictum: Someone who doesn't have a good command of her native
  20. tongue cannot be a good programmer (excuse me for not quoting verbatim,
  21. but I am at the moment separated from my reference library).  Things are
  22. not quite that simple, but writing a professional program is an act of
  23. communication, and cannot be mastered without knowledge of the art of
  24. technical writing. 
  25.  
  26. You rightly emphasise using 'the most specific construct'.  This, to my
  27. mind, is the central principle of technical communication, although 'the
  28. most appropriate construct' might be a better way of putting it.  Strunk
  29. & White put it in their usual admirably terse and concrete style: 'the
  30. right word in the right place' (I also don't have my style guides handy,
  31. but I think I remember that right). 
  32.  
  33. Data abstraction is A GOOD THING.  Therefore everything that can be
  34. represented as a data structure should be have an accessor and a setf
  35. method, and possibly a creator, mapping functions, etc. 
  36.  
  37. There should probably be a whole chapter on the pitfalls of complex setf
  38. methods.  I might write that chapter when I return my erstwhile
  39. employer, Harlequin, and regain access to some good examples of them. 
  40.  
  41. The VALUES form is not a good indicator of how many values are being
  42. returned, especially when the values are just being passed through:
  43. (VALUES (FLOOR X Y)).  Why not just use comments? Commenting the
  44. arguments and return values of all functions external to a module is a
  45. good principle. 
  46.  
  47. SETF (VALUES ...) is a handy idiom, when you don't want to create a data
  48. structure for a set of values that form a conceptual unit. 
  49.  
  50. CATCH and THROW have their place, when you truly want dynamic scope and
  51. a restart is not appropriate.  They could, however, often be replaced by
  52. using RETURN-FROM encapsulated in a closure, a technique a CL programmer
  53. should understand anyhow. 
  54.  
  55. Macros are a major reason why Lisp is such a great language to write
  56. programs in.  They are a great aid to clarity, if used adroitly.  Macro
  57. writing is the touchstone of a Lisp programmer's skill.  Therefore do
  58. beware, but do dare!
  59.  
  60. It is useful to develop a toolkit for writing complex macros.  Using
  61. GENSYM to prevent the capture of lexical names (note: block, tag,
  62. function, and macro names as well) is just the beginning.  (MAKE-SYMBOL
  63. original-name) is better than GENSYM when you have to debug the
  64. expansion.  DESTRUCTURING-BIND is handy, the only problem is that many
  65. implementations don't do much error checking.  One that does, like
  66. Harlequin's, is a great aid to syntax checking. 
  67.  
  68. I didn't quite get what you mean by asymmetric REDUCE?
  69.  
  70. FORMAT ~A is an invitation to false assumptions because it hides
  71. information.  FORMAT also deserves a chapter of its own, even though
  72. 'FORMAT style' sounds like an oxymoron. 
  73. __
  74. Pekka P. Pirinen         pekka.pirinen@helsinki.fi
  75. University of Helsinki, a once and future harlequin
  76.