Paralife
Paralife

Reputation: 6236

Lisp: Problem with package prefix in macro/function definitions

I want to create a macro (or function) which will contain package-prefixed symbols. This is possible only if those packages have already been defined. Why? As long as i have defined the packages by the time the macro/function gets called, why is there a problem if they are undefined when the macro/function is defined?

The reason I want this is that i want to have convenience functions in my init file for starting-stopping stuff i develop in different projects-packages but I dont want to load all the projects just to be able to define the convenience functions, since i only develop one project at a time.

Upvotes: 1

Views: 245

Answers (2)

Rainer Joswig
Rainer Joswig

Reputation: 139251

(funcall (find-symbol "RENDER-SUPER-FANCY-GRAPHICS"
                      "THIS-PACKAGE-DOES-NOT-YET-EXIST")
         *standard-output* :width 1000 :height 800)

Upvotes: 3

Xach
Xach

Reputation: 11854

The source code is read by the Lisp reader before evaluation (see read). The reader can't intern the symbols if the packages aren't already defined.

Upvotes: 7

Related Questions