Daily Static

Technology, Dynamic Programming and Entrepreneurship

This page is powered by Blogger. Isn't yours?
Monday, February 24, 2003
Lisp Debugging error

I was walking through the Emacs Lisp tutorial today, trying to write
the insert-buffer function. I must have spent two hours trying to
figure out why my function wouldn't work. I kept comparing it to the
example provided, and the two looked identical to me. I even opened
up the insert-buffer function that is loaded into emacs and compared
it, still they looked indentical to me. Finally I identified the
problem. My insert-substring was written like this:
(insert-substring (oldbuf start end))

while it may look obvious to people familiar with lisp what the problem
was, this syntax looked natural to me. It's interesting that my
background with algebraic notation actually made the error invisible
to me.
In lisp function's are called like this:
(function-name arg1 arg2 arg3 ...) ;; Lisp Syntax
The parenthesis surround the function call as a whole, but do not
surround the parameters specifically like so:
function-name (arg1, arg2, arg3, ...) // C style syntax

I imagine this is something that is going to happen to me fairly
frequently as I begin writing lisp code, however now it's on my list
of things to be on the look out for.

It's interesting to note, even though I've only been using Lisp for a
short time, I find my self thinking about it constantly. I wonder
how to do things like embedding the script interpreter inside of my
programs. Apparently this is quite easy to do in Lisp. This takes a
fair amount of effort however in most other programming languages. I
feel like I'm starting to get a sense of Lisp and some of the power it has to
offer, It will be interesting to see where this journey takes me.

Comments: Post a Comment