Levi's Lisp Log

Thoughts and links relating to Lisp and computer theory

Dangers of Destructive Functions

While finishing up the templates for the site, I ran into a little problem--suddenly, each type of page would only render one set of entries despite instructions to the contrary. After a good bit of debugging (inspect is my friend), I found the culprit: nconc.

The html-template library requires passing in a plist to the template printer in order to fill template variables. Originally, everything in the plists was generated on-the-fly, so nconcing them together wasn't an issue. However, I ended up adding a static plist entry at the end of one plist-returning function, and the first nconc after a compile would append all sorts of entries to the end of that one, making them part of the static data as well.

Lesson learned: Start out with non-destructive functions, and only optimize to destructive versions when it is necessary and safe to do so!

# Posted by: Levi at 01:23 AM on Tuesday, September 13, 2005
   Comments: (0) Categories: Lisp

Post a Comment

Name:
Email:
URL:
What is the square root of 4?:
Comment: