This is a collection of blog entries written while learning Lisp. It is posted in the order written so you probably want to jump to the first post.

Tuesday, October 16, 2007

Practical Common Lisp Chapter 5 : Functions

When reading the online version of the book it would be really nice to be able to click on a footnote number to read it and then have a link to go back to the place of the footnote. The following example just begs to be clicked:

Any symbol can be used as a function name.2

Coming from C++ and Qt where everythingIsCamelCase I will have to get used to functions-with-dashes, but I will try. The fact that functions can have built in documentation is really very cool. One of those, "why don't more languages have this?" features.

As the title went this chapter was all about functions, the first half was on parameters; optional, rest, and keyword. Lisp has some really nice parameter features that are not present in other languages. A little confusing. Then it talked about passing functions and using FUNCALL, APPLY, and lastly anonymous functions. Snuck in the middle it explained RETURN-FROM and introduced blocks (more to come about that in a future chapter). The chapter was low on stuff I could type and try (and screw up) in emacs and I felt myself forcing myself though it, but I honestly don't know how it could have been shorter. There was a bunch to cover, much of which will never be used (from the sounds of it) like keyboard, but still a very good thing to be aware of when you come across it later when reading code. It might have been cool to first try to do something in c or c++ and then when you can't show how you can do it in Lisp, but that would just make this chapter longer.

No comments: