[Top][All Lists]

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

Re: Fixing "Unknown slot" warnings

From: David Engster
Subject: Re: Fixing "Unknown slot" warnings
Date: Sun, 29 Jan 2017 16:35:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Stefan Monnier writes:
>> How can I tell the compiler everything will be OK at runtime, similar to
>> what 'declare-function' does for functions?
> I don't think we have something for that right now.
> Maybe you can try something like:
>     (eval-when-compile (defclass dummy () ((SLOT))))
> Better would be to wrap this into an `eieio-declare-slot` macro (which
> could later be replaced by something which doesn't end up defining
> a class as a side-effect).

After looking at the code, it seems all slot symbols are shoved into
`eieio--known-slot-names' and the byte-compiler checks if a slot is in
there, regardless of the class being used. So the following would
already do the trick:

(defmacro eieio-declare-slot (name)
  "Declares slot to be available at runtime."
  `(eval-when-compile (cl-pushnew ,name eieio--known-slot-names)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]