0

I'm using mod_lisp along with the modlisp-clisp.lisp file at http://www.fractalconcept.com/fcweb/download/modlisp-clisp.lisp. I want to load different packages based on the server-id field so I can have different sites set up. I was trying to do this with

(server-id:fetch-content request)

with server-id quoted and unquoted, but it couldn't find the package. Some document-hunting found me find-package, but when I do

((find-package server-id):fetch-content request)

it says

(FIND-PACKAGE SERVER-ID) should be a lambda expression.

How can I load a package given the package name as a string?

2 Answers 2

1

If you want to use different symbols when calling functions, you have to compute them.

(funcall (find-symbol (compute-the-name) (compute-the-package))
         arg1 ... argn)

Note that both package and symbol names are usually uppercase strings.

CL-USER 6 > (funcall (find-symbol "EXPT" "CL") 3 4)
81

Note that you should not let the user over the network specify arbitrary functions and arguments which are then called without error checking.

Sign up to request clarification or add additional context in comments.

Comments

0

Common Lisp packages are what other systems call namespaces.

You have to use load or require - or whatever the documentation instructs you to do - to make the desired functionality (including the packages and functions) available.

Once the code is loaded into Lisp, you can use list-all-packages to see which packages are now available.

2 Comments

I know, I'm doing that. The file is getting loaded but if I call a function defined in that file it's not recognized. So I was trying to prefix the package name onto the function but don't know how to get from the string to something I can use as a package name.
are you running in modern mode (non-case-converting)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.