Function Hierarchy?
20-Feb-92 00:21:59
Sb: #33790-Function Hierarchy?
Fm: Tony Tanzillo [LISP TM] 71241,2067
To: Phillip E. Rutledge 70421,3012
Another benefit of this 'modular' or layered approach to development is that
since a code fragment can appear once, and be referenced or called from many
places, it becomes much easier to maintain, modify, and enhance the function
or procedure, since all changes are isolated in one single location, and if
you've ever written a large application, you'll appreciate the benefits of a
modular approach to its design.
My favorite example of a useful 'subroutine' is also the one I use the most.
Every time you need to pull a value out of an entity data list, or another
type of association list, you use the ASSOC and CDR functions. Since I do
this often, I doesn't pay for me to write it like this:
(setq color (cdr (assoc 62 <list> )))
This is fine if you only need to do it once or twice, but in my case, I can
save some code, and reduce the complexity of what code I have, using a small
"macro" function for the above:
(defun get (key alist)
(cdr (assoc key alist))
)
With this, whenever I need a value from an association list, I can do it with
a call to just one function, rather than two:
(setq color (get 62 <list> ))
For one who is familar with the function of the (GET) subroutine, this form
will be much clearer, and more effecient.
-TonyT.