This is a read-only archive!

*sigh*

I spent four hours working on my photo-blog in Common Lisp that I've mentioned earlier.

Why does Common Lisp hate me? After four hours, I'm not yet even to the point where I can reliably, successfully load all the libraries I need to load. How pathetic is that? I haven't even gotten to the point where I could, you know, actually write my program.

This article explains how to set up an ASDF system file. I'm using ASDF because you almost HAVE to use it if you're utilizing any 3rd-party libraries, because so many 3rd-party libraries use ASDF themselves and because I wouldn't know where to begin to write my own dependency-resolution scripts from scratch.

So my ASD file has all the right dependencies, so all the libraries load in the right order and Lisp knows they exist. Then I have a packages.lisp that defines my package. Then I have a main source file with all my code in it, which is IN-PACKAGE my package. This all appears to work.

As long as I fully-qualify every function that comes from another package, it works fine. Problem is that if I try to (:use :cl-who) in my package, to avoid having to endlessly repeat myself every time I use a function from CL-WHO, I get a flood of warnings saying:

undefined variable: PRINC

Funny, because PRINC is a built-in function in Common Lisp. And PRINC is defined in my package. And if I IN-PACKAGE to CL-WHO, it's accessible from there too.

Can I use ASDF and still have my package inherit functions from other packages? This is the great mystery which I have been completely unable to solve. Is this some compile-time vs. runtime mess that only exists in Common Lisp? Am I accidentally interning symbols and obliterating other packages' symbols? Am I just mentally retarded?

This is extremely frustrating. I don't care how wonderfully great your programming language is: if you have to arm-wrestle the thing for a week to get your environment set up, what's the point? How can something so simple as importing functions from other packages be so difficult?

I could've had everything done already if I'd have used Ruby. I could gem install what I need, and then require it and wow, it works. Hell, I could've had this done in PHP or Perl by now.

If I ever get CL working on my machine, then I have to worry about installing SBCL and all these libraries and mod_lisp and whatnot on my Debian server. God almighty, I don't even want to think about that.

January 09, 2008 @ 7:54 PM PST
Cateogory: Programming
Tags: Lisp, PHP, Ruby, Rant

5 Comments

Zach Beane
Quoth Zach Beane on January 09, 2008 @ 9:40 PM PST

:use specifies the complete list of packages imported into your new package. If you :use only :cl-who, you are no longer using the COMMON-LISP package, so standard symbols like PRINC aren't visible without a CL prefix.

To fix it, make sure :cl is in your :use list. Just like in the little tutorial you link to.

Brian
Quoth Brian on January 10, 2008 @ 4:23 AM PST

Thanks for the tip. I did have :cl in the list also, it doesn't make any difference.

Zach Beane
Quoth Zach Beane on January 10, 2008 @ 4:26 AM PST

If you have

(defpackage :foo (:use :cl :cl-who))

(in-package :foo)

You can then use CL symbols and CL-WHO symbols in FOO without using package prefixes.

It's hard to offer advice when you write one thing in your blog and a different thing in your source code.

Brian
Quoth Brian on January 10, 2008 @ 4:55 AM PST

Sorry, advice wasn't really my goal. Just venting frustrations. I plan to figure this out myself eventually.

Zach Beane
Quoth Zach Beane on January 10, 2008 @ 6:02 AM PST

Fair enough. I hope someone else searching for a solution to a similar problem won't find this entry and leave with the impression that Lisp has some fundamental problem.

The solution, if you want PRINC (or other standard CL symbols) to be available directly in a package, is to make sure the new package uses the CL package. That will happen if CL is one of the packages listed in the defpackage :use list, or if you evaluate (use-package :cl), or in a number of other ways.