Reputation: 1
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?
Upvotes: 0
Views: 844
Reputation: 139241
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.
Upvotes: 1
Reputation: 60004
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.
Upvotes: 0