Page 1 of 2

Yet another Lisp related screencast

PostPosted: Mon Dec 15, 2008 2:43 am
by Alexander Lehmann
Hi there,

because I liked the excellent Lisp screencasts of Marco Baringer and Rainer Joswig and due to the lack of additional freely available stuff like the beforementioned, I've thought about creating comprehensive tutorial-like screencasts myself. So, during the past summer I began with the creation of a tutorial on writing a simple raytracer in Common Lisp, consisting of multiple screencasts. As I unfortunately do not have the time for further work on it, I finally decided to make the present state available.

Please note that I do not claim to be a Lisp uber-professional and thus you may or may not encounter a few mistakes. The ones I know about have been mentioned and corrected in the subsequent screencast respectively.

If you like what you see or should you wish to contact me, I'm looking forward to hearing from you. You can find my email address as well as the mentioned work at http://home.in.tum.de/~lehmanna/lisp-tutorial.html.

Also, please note that the first part is a neccessary prerequisite for its successors. Anyways, IMHO the more interesting and explanatory stuff starts from Part 2.

Re: Yet another Lisp related screencast

PostPosted: Mon Dec 15, 2008 4:11 pm
by Paul Donnelly
Code: Select all
(defun (setf matrix-at) ...)

Wait, I can do that?

Re: Yet another Lisp related screencast

PostPosted: Mon Dec 15, 2008 4:37 pm
by Alexander Lehmann
Yes, definitely :)

Re: Yet another Lisp related screencast

PostPosted: Mon Dec 15, 2008 6:13 pm
by Paul Donnelly
Alexander Lehmann wrote:Yes, definitely :)

You learn something new every day. 8-) I'd been using DEFSETF this whole time.

Re: Yet another Lisp related screencast

PostPosted: Tue Dec 16, 2008 10:48 pm
by August
Paul Donnelly wrote:
Code: Select all
(defun (setf matrix-at) ...)

Wait, I can do that?


August the newb here...what does this do? I did a macroexpand-1 and compared it to a regular defun but still don't get it :oops:

Re: Yet another Lisp related screencast

PostPosted: Wed Dec 17, 2008 1:25 am
by Alexander Lehmann
This basically defines a new setf expander. You might want to look up defun, defsetf and the like in the CL HyperSpec for a more detailed unterstanding. However, in the case of the matrix it allows an aref-like access of the matrices elements both for reading and writing.

Re: Yet another Lisp related screencast

PostPosted: Wed Dec 17, 2008 4:55 am
by Paul Donnelly
August wrote:
Paul Donnelly wrote:
Code: Select all
(defun (setf matrix-at) ...)

Wait, I can do that?


August the newb here...what does this do? I did a macroexpand-1 and compared it to a regular defun but still don't get it :oops:

It makes it so that not only can a person do
Code: Select all
(matrix-at a b)

, they can also do
Code: Select all
(setf (matrix-at a b) c)

. There are about four ways (and counting? :roll: ) ways to define setf expanders, but this is the most concise.

Re: Yet another Lisp related screencast

PostPosted: Wed Dec 17, 2008 12:32 pm
by August
Alexander Lehmann wrote:This basically defines a new setf expander. You might want to look up defun, defsetf and the like in the CL HyperSpec for a more detailed unterstanding. However, in the case of the matrix it allows an aref-like access of the matrices elements both for reading and writing.


Thank you very much for the help guys! I did look in the Hyperspec a bit but wasn't quite able to piece it all together.

Re: Yet another Lisp related screencast

PostPosted: Wed Dec 17, 2008 12:58 pm
by Paul Donnelly
August wrote:Thank you very much for the help guys! I did look in the Hyperspec a bit but wasn't quite able to piece it all together.

It's like that sometimes. Less so once you get the hang of its conventions and precise vocabulary, but look at how I got surprised by this way of defining setf expanders. I still have no idea where it's described.

Re: Yet another Lisp related screencast

PostPosted: Wed Dec 17, 2008 2:51 pm
by qbg
Paul Donnelly wrote:I still have no idea where it's described.

Well, defun takes a function name as its first argument, and a function name is "1. (in an environment) A symbol or a list (setf symbol) that is the name of a function in that environment. 2. A symbol or a list (setf symbol)."