[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Object Lisp Question



   From: sbchanin@ai.mit.edu (Steve Chanin)

   I get:

	Compiler warnings for function ED-SET-SMALL :
	  Undeclared free variables (SMALL-SIZE SMALL-POS)

A 'free reference' is any reference to a variable that is not
bound by some lexical construct surrounding the reference.  An
'undeclared free variable' is a free reference to a variable that
the system doesn't know about.  That is, it hasn't been proclaimed
special, or declared as a global variable by DEFVAR or DEFPARAMETER,
etc.

Object Lisp implements object variables as free variables, which are
looked up 'inside' the current object.  To suppress the warning,
you simply declare the references as variable references.

(defobfun (foo my-object) (val)
  (declare (object-variable my-var))
  (list val my-var))

or

(defobfun (foo my-object) (val)
  (list val (objvar my-var)))

   The code works fine (i.e. it creates a small-size variable in the
   particular fred window), but I'm curious about why this warning is
   generated.  I know that replacing the (setq small-size ...) with
   (setf (symbol-value 'small-size) ...) makes the warning disappear, but this
   seems verbose.

Yes, please avoid using symbol-value in these cases.

    -andrew