Not sure about package management in Lisp

Discussion of Common Lisp

Not sure about package management in Lisp

Postby jreeseUE » Thu Jul 28, 2011 8:01 am

Hello, I have been learning Lisp through the 'Common Lisp Cookbook' recently and am having some trouble with package management. I have created two files: packages.lisp and pathnames.lisp that look as follows:
packages.lisp:
Code: Select all
(defpackage :edu.american.spam
  (:use :common-lisp :edu.american.pathnames))

pathnames.lisp
Code: Select all
(in-package :edu.american.spam)

However, when I run pathnames.lisp this is what I'm getting:
Code: Select all
11:01@host:.+ments/lisp/spam$ clisp pathnames2.lisp
*** - SYSTEM::%FIND-PACKAGE: There is no package with name "EDU.AMERICAN.SPAM"


Any help would be most appreciated. Thanks.
jreeseUE
 
Posts: 5
Joined: Thu Jul 28, 2011 7:47 am

Re: Not sure about package management in Lisp

Postby nuntius » Thu Jul 28, 2011 9:32 am

Side note: example.com is the canonical domain name for examples.

As to your problem, clisp is being told to load pathnames.lisp but not packages.lisp; thus it is never being told to look at the package definition.

At a higher level, don't treat lisp like a C/C++/Java compiler. Treat the compiler as you're program's "main" -- as the foundation of any application.
Thus it is common to open CL as a command shell (REPL in lisp parlance) and interactively load files or even type definitions directly.
Slime is a popular Emacs plugin that provides a powerful REPL interface.
ASDF is a popular tool for compiling and loading multiple files as part of a single "system" (library).
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: Not sure about package management in Lisp

Postby pjstirling » Sat Jul 30, 2011 12:27 pm

Something that will bite noobies is that the slime documentation DOESN'T setup the REPL by default
Code: Select all
(slime-setup 'slime-fancy)
should (and used to) be the default and isn't any more.
pjstirling
 
Posts: 78
Joined: Sun Nov 28, 2010 4:21 pm

Re: Not sure about package management in Lisp

Postby jreeseUE » Sun Jul 31, 2011 8:02 am

Great. Thanks for your replies...I am slowly working through this setup stuff.

I had slime working until I tried the 'slime-fancy addition. My .emacs:
Code: Select all
(setq inferior-lisp-program "sbcl")
(require 'cl)
(push "/usr/loca/bin" exec-path)
(push "/usr/texbin" exec-path)
(push "/usr/local/share/emacs/site-lisp" load-path)
(autoload 'imaxima "imaxima" "Maxima frontend" t)
(autoload 'imath "imath" "Interactive Math mode" t)

(add-hook 'c-mode-hook 'turn-on-font-lock)
(show-paren-mode)
(setq make-backup-files nil) ;; do not make backup files                       
;;keyboard navigation                                                           
(define-key global-map (kbd "RET") 'newline-and-indent)
(global-set-key "\C-n"(lambda () (interactive) (next-line 5)))
(global-set-key "\C-p" (lambda () (interactive) (next-line -5)))
(global-set-key "\C-u" (lambda () (interactive) (next-line -1)))
(global-set-key "\C-o" (lambda () (interactive) (next-line 1)))

(setq inferior-lisp-program "/opt/local/bin/sbcl") ; your Lisp system           
(add-to-list 'load-path "~/.emacs.d/slime")  ; your SLIME directory             
(require 'slime)
(slime-setup 'slime-fancy)

error caused from 'slime-fancy addition:
Code: Select all
Warning (initialization): An error occurred while loading `/Users/joshreese/.em\
acs':

Wrong type argument: listp, slime-fancy


Seems to work find without the 'slime-fancy
jreeseUE
 
Posts: 5
Joined: Thu Jul 28, 2011 7:47 am

Re: Not sure about package management in Lisp

Postby pjstirling » Sun Jul 31, 2011 9:34 pm

Yes, your error is my fault, sorry. I forgot that you still need a list even if you only want one.

Code: Select all
(slime-setup '(slime-fancy))


My own .emacs uses
Code: Select all
(slime-setup '(slime-fancy slime-tramp slime-asdf))
pjstirling
 
Posts: 78
Joined: Sun Nov 28, 2010 4:21 pm

Re: Not sure about package management in Lisp

Postby jreeseUE » Tue Aug 02, 2011 2:42 pm

Nice...this works just fine. Thanks again.
jreeseUE
 
Posts: 5
Joined: Thu Jul 28, 2011 7:47 am


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 4 guests

cron