From: David Young

Subject: Warning during macro expansion

Date: 1999-10-21 14:01

Greetings. I've a couple of macros (one simple, the other a bit more
ambitious) used by a simulation system we're building. These macros
are simply syntactic sugar for CLOS constructs (defclass, defmethod);
examples are:

(defmacro defcommand (opcode)
  "Defines and makes available a new command to JEM."
  `(defclass ,opcode (command)
     ()))

(defmacro defbehavior (opcode cmd &body body)
  "Attaches behavior to a particular JEM command."
  `(with-command-class (,opcode)
     (defmethod execute ((,cmd ,opcode))
       <body))) at ,>

After loading the file that contains these macros, and loading a file
that uses them, all is well. Example:

 (defcommand ENT-EQPT)

 (defbehavior ent-eqpt self
   (format t "Behavior for ~S:~%" self)
   (format t "  opcode: ~S~%" (get-opcode self))
   (format t "  parameters: ~S~%" (get-parameter-list self)))

However, if I then redefine an existing command from the Lisp Listener:

  (defcommand ENT-EQPT)

Lisp tells me:

  Warning: ENT-EQPT, :TYPE was defined in /files/devel/ontologies/jem/src/command/standard-set.lisp and is now being
           defined at the top level
  #<STANDARD-CLASS ENT-EQPT>

I get similar behavior from (defbehavior), and the same behavior if I
first enter these forms from the Listener and *then* load the file
using these macros.

FYI, the macro expansion of (defcommand) is:

(PROGN NIL
       (EVAL-WHEN (COMPILE)
         (EXCL::CHECK-LOCK-DEFINITIONS-COMPILE-TIME 'ENT-EQPT :TYPE 'DEFCLASS (FIND-CLASS 'ENT-EQPT NIL)))
       (EXCL:RECORD-SOURCE-FILE 'ENT-EQPT :TYPE :TYPE)
       (CLOS::ENSURE-CLASS-1 'ENT-EQPT :DIRECT-SUPERCLASSES '(COMMAND) :DIRECT-SLOTS (LIST)))

I'm running ACL 5.0 on Linux. Thanks for any help.

Regards,

-- 

-------------------------------------------------------------
David E. Young
Fujitsu Network Communications  "The fact that ... we still
<nc.fnc.fujitsu.com) at (dey>         live well cannot ease the pain of
                                 feeling that we no longer live nobly."
                                  -- John Updike
"Programming should be fun,
 programs should be beautiful"
  -- P. Graham