Sure you can learn lisp by starting with the language specification and working your way up from there but it is not exactly in your face is it. It's not of today. We who want to learn want to be sent home crying nowadays by panel of masochistic has beens. I feel that computerlanguage learning should keep up with this degrading trend if we want to have any chance of attracting the youngsters of today. That's why i want to show a route to lisp with a bit more streetcred. Enter the UCW school of hard knocks.
It's a webframework, UCW. Nothing more hip than a webframework. It's hip enough for me anyway. Ai, didn't mean to say hip. But i really like it as a mentor. Initially it is more of a meta-tutor: Step one for your average clueless lisp newbie is downloading the source-code and start staring at those parenthesis. If the only syntax you can distill is that they should match, it's time he should read the theoretical chapters of Practical Common Lisp.
Ah ok, i'll admit. It's me i'm talking about. Let's keep this text honest. And i read those chapters before I downloaded UCW. But afterwards i knew i didn't need more education and i could start coding. But i wanted to do it in UCW so at least i should read the source code. I stumbled into the html-generating code and got hit by a mother of a macro. With my tail between my legs i backed off, leaving some pee behind. My pride was hurt but i had to accept my ineptness. So i downloaded On Lisp and i read the first couple of theoretical chapters to get to grips with those scary lisp monsters. Very pretty code in there. And i curse it, for now i will never want to program in a lesser language again. Oops, did i say lesser? Curse you Graham!
In On Lisp i read something about continuations and i knew UCW used the concept so I thought that route was kind of safe. Stopping in front of them revealed they were exactly the kind of continuations Graham didn't touch upon: The ones using a code walker. There wasn't that much introductionary material for this one unfortunately but as i noticed, but i figured usually Bill Clementson has an interesting post or two about a subject like this, and well he didnt let me down. The last link brings you to what i was searching for Macroexpand-all: An Example of a Simple Lisp Code Walker. It's pre-ansi and so some techniques are made redundant, not to mention the purpose of the thing, but the principle is tries to convey is still sound.
Back to UCW again!! This time i actually went back to the topic i left when leaving my meta-teaching-environment. And indeed the UCW code-walker sort of functioned like the one in the example. Or i guess. It does the special form lookup thing in a lookup table and then returns a function to handle it, but as you might expect it does a bit more that macroexpand. I was glad the spagetti made some sense to me but not far in the file i hit another bump: mop. And i thought bad thoughts. Will the list of fancy lisp utensils never stop?? Again an online tutorial was hard to find, but User-Level Language Crafting: Introducing the CLOS Metaobject was rather nice I thought.
This brings the time pointer to about a week ago. Mind you, by this time I still had written zero constructive lisp code, and I hardly read any UCW code. But the time was well spent because the concepts learned are of such a beauty that they make grown men weep. Also i can now sort of understand the ucw code and i can almost advance to semester two of the UCW school of hard knocks. For proper advancement i want to go through the source-code of Dojo which is now used by UCW itself, but i'm getting a bit impatient. The last couple of days i browsed UCW's form handling routines and i got hit by the latest UCW knock. Mr Baringer (ucw creator) banished the code to a seperate library and came with a more pragmatic approach. But again reading the code has it's own benifits. In one of the removed files i came across this macro, and your clueless newbie got a bit confused by the setf tactic:
(defmacro with-simple-restore (places &body forms) "Preserve values of setfable PLACES before execution of the FORMS and restore them after. Returns the result of the FORMS." (let ((keepers (mapcar #'(lambda (p) (declare (ignore p)) (gensym)) places))) `(let ,keepers (setf (values ,@keepers) (values ,@places)) (prog1 (progn ,@forms) (setf (values ,@places) (values ,@keepers))))))But appearently it's perfectly legal to first supply setf with a slew of values and after that a slew of places with (values ...). I wouldn't have thought of that one and yet it makes perfect sense.
This undermines a bit the premise of the first paragraph of course but i doubt any reader actually got this far.
Ha! You wish... ;)
Enlightening... to and old lisper. Thanks. (Sorry about the leg, though.)
It's "Seibel" and "Clementson".
It's "Seibel" and "Clementson".
ai, ai, shamefull. I hate when that happens.
Just keep ploughing through those books, they are good. Keep it up. And yes UCW is the school of hard knocks.
funny post. you're doing more than fine with just a few months into lisp and ucw.
pick your battle wisely. i give up on ucw after 2 months of trying to understand the code. cps interpreter and mop are the show stoppers for me
nice post! I'm taking the same lisp-journey and recognise the reading-marathon that one have to put in. The fun thing is when you realise that you are moving forward. My short time goal is to put my first app on the web! You will See when it happens.
The prime number-thing was to hard for me, I had make a lispprogram solve it.. why think when you can make the computer do it for u.