1

I get this error:

Error: Class named ENTITY not found. While executing: FIND-CLASS, in process Listener(4). Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts. If continued: Try finding the class again Type :? for other options.

When I load/compile a file with this macro in it:

(defmacro def-post-entity (entity)
   (let* ((repository-var-name (cl-ddd::repository-var entity))
          (base-url (string-downcase (concatenate 'string "/api/" (string entity))))
          (progn-statement '(progn)))
     (loop 
       for slot in (ccl:class-slots (find-class entity)) 
       append `(setf (,(ccl:slot-definition-name slot) new-entity)  
               (cdr (assoc ,(string (ccl:slot-definition-name slot)) params :test #'string=)))
       into progn-statement)
      `(setf (ningle:route cl::*app* ,base-url :method :post)
             (lambda (params)
               (let ((new-entity (make-instance ,entity)))
                 (,progn-statement))))))

As I understand lisp macros (I'm new), there's no reason for find-class to expect entity to be a classname, it's a parameter to the macro. The error message indicates that find-class is being executed, but it's not. I'm just loading the file containing this macro via (ql:quickload "filename") or compile it directly.

Any help would be appreciated in helping me to understand what's happening, and to fix it.

Jim Barrows
  • 3,634
  • 1
  • 25
  • 36
  • What happens when you only do `(load "filename")`? `quickload` is for loading systems, which can load other files and which could explain why `find-class` *is* being executed. – coredump Oct 23 '15 at 07:22
  • Compilation does the same thing. – Jim Barrows Oct 23 '15 at 14:24
  • 2
    One thing that is definitely wrong is the handling of `progn-statement`. You are shadowing the binding inside the `loop`, then throwing it away. – Svante Oct 23 '15 at 14:45
  • I pasted your code with additional package definitions for ningle and cl-ddd (see http://pastebin.com/raw.php?i=ewZEbjTt) but neither loading nor compiling the file with CCL brings the issue you mention. We are missing some context here. – coredump Oct 23 '15 at 14:48
  • How do you call `def-post-entry`? Do you use a variable named `entity`as a parameter in the call? As the macro argument is not evaluated, it must be a symbol that names a class, not a variable that evaluates to such a symbol. – Terje D. Oct 25 '15 at 09:15

1 Answers1

1

The problem was the macro AFTer this one, where I call def-post-entity. It's a macro as well, and I forgot that that would mean def-post-entity gets expanded there as well.
Coredumps comment helped me figure it out.

Jim Barrows
  • 3,634
  • 1
  • 25
  • 36