From: Haris Bogdanovi� on
I'm trying to install packages like this:

(require 'asdf)

(let 'packs '(md5 CL-BASE64 RFC2388 CL-FAD trivial-backtrace usocket
Bordeaux-Threads CL+SSL FLEXI-STREAMS Chunga CL-PPCRE CL-WHO Drakma
hunchentoot)
(dolist (item packs)
(progn
(push (make-pathname :device "c" :directory '(:absolute "lisp" "sbcl"
"site" (symbol-string item))) asdf:*central-registry*)
(asdf:oos 'asdf:load-op item))))

But it doesn't work ?


From: Captain Obvious on
HB> I'm trying to install packages like this:

Installing or loading?

HB> (require 'asdf)

HB> (let 'packs '(md5 CL-BASE64 RFC2388 CL-FAD trivial-backtrace usocket
HB> Bordeaux-Threads CL+SSL FLEXI-STREAMS Chunga CL-PPCRE CL-WHO Drakma
HB> hunchentoot)
HB> (dolist (item packs)
HB> (progn
HB> (push (make-pathname :device "c" :directory '(:absolute "lisp"
HB> "sbcl" "site" (symbol-string item))) asdf:*central-registry*)
HB> (asdf:oos 'asdf:load-op item))))

HB> But it doesn't work ?

Definitely. Your LET is wrong. It should be (let ((packs '(whatever))) ...)

From: Haris Bogdanovic on
Now I get

(SYMBOL-STRING ITEM) is not allowed as a directory component

If I type (symbol-string 'a) in repl it says that symbol-string function is
undefined,
but when trying to autocomplete symbol-string, it works.
How do I convert a symbol to a string ?

Thanks



From: Haris Bogdanovi� on

> (SYMBOL-STRING ITEM) is not allowed as a directory component

Sorry, I typed that wrong:

(symbol-name item) or
(string item)
both give me the error:

(SYMBOL-NAME ITEM) is not allowed as a directory component or
(STRING ITEM) is not allowed as a directory component

Why when both expressions return string which obviouslly can be a part of
directory name ?



From: Captain Obvious on
HB> Now I get

HB> (SYMBOL-STRING ITEM) is not allowed as a directory component

A problem with it is that it is inside a quote. Everything inside the quote
is taken literally, as data, and is not executed.

CL-USER> '(:absolute "lisp" "sbcl" "site" (symbol-string 'item))
(:ABSOLUTE "lisp" "sbcl" "site" (SYMBOL-STRING 'ITEM))


HB> If I type (symbol-string 'a) in repl it says that symbol-string
HB> function is undefined,

Because it is actually SYMBOL-NAME

HB> but when trying to autocomplete symbol-string,

This just means that there is interned symbol symbol-string, it doesn't mean
that it is fbound.

So, if you want symbol-name to be executed, you should either use LIST
function to create a list:

CL-USER> (list :absolute "lisp" "sbcl" "site" (symbol-name 'item))
(:ABSOLUTE "lisp" "sbcl" "site" "ITEM")

Or use backquote (aka quasiquote) -- it like a templating construct which
allows you to have both evaluated parts and literal parts in list.

CL-USER> `(:absolute "lisp" "sbcl" "site" ,(symbol-name 'item))
(:ABSOLUTE "lisp" "sbcl" "site" "ITEM")

Note the comma -- it says that this part should be evaluated.

Also note that niether quote (') nor backquote (`) are list constructors,
per se. They just take things that reader reads literally (or, almost
literally). List itself is contructed by reader when it reads a form with
parentheses.

 |  Next  |  Last
Pages: 1 2
Prev: land of lisp
Next: Iterate and count