* Fixing "Unknown slot" warnings
@ 2017-01-29 12:39 David Engster
2017-01-29 14:41 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: David Engster @ 2017-01-29 12:39 UTC (permalink / raw)
To: emacs-devel
I'm currently fixing the above byte-compiler warnings for CEDET. I've
replaced all the 'oref' with 'slot-value' and properly used quotes for
the slot names, but there are some warnings remaining. The reason is
that the byte-compiler has not seen the class declaration, so it does
not know about the available slots. However, I cannot simply
eval-when-compile-require the file with the class as it would create a
circular dependency.
Example: Compiling lisp/cedet/semantic.el issues
In semantic-analyze-completion-at-point-function:
cedet/semantic.el:1188:15:Warning: Unknown slot ‘bounds’
The class declaration for `semantic-analyze-context' is in
semantic/analyze.el, which however itself requires semantic.
How can I tell the compiler everything will be OK at runtime, similar to
what 'declare-function' does for functions?
-David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing "Unknown slot" warnings
2017-01-29 12:39 Fixing "Unknown slot" warnings David Engster
@ 2017-01-29 14:41 ` Stefan Monnier
2017-01-29 15:35 ` David Engster
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2017-01-29 14:41 UTC (permalink / raw)
To: emacs-devel
> 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).
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing "Unknown slot" warnings
2017-01-29 14:41 ` Stefan Monnier
@ 2017-01-29 15:35 ` David Engster
2017-01-29 17:07 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: David Engster @ 2017-01-29 15:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
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)))
-David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing "Unknown slot" warnings
2017-01-29 15:35 ` David Engster
@ 2017-01-29 17:07 ` Stefan Monnier
2017-01-29 21:26 ` David Engster
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2017-01-29 17:07 UTC (permalink / raw)
To: emacs-devel
> 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)))
If you mean something to add to eieio, then yes, that's about right
(tho you could also do it as (defmacro eieio-declare-slot (name)
(cl-pushnew name eieio--known-slot-names) nil).
My `defclass` solution was meant for use in code that must work with
older Emacsen and/or older eieio without relying on internals like
eieio--known-slot-names.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fixing "Unknown slot" warnings
2017-01-29 17:07 ` Stefan Monnier
@ 2017-01-29 21:26 ` David Engster
0 siblings, 0 replies; 5+ messages in thread
From: David Engster @ 2017-01-29 21:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier writes:
>> 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)))
>
> If you mean something to add to eieio, then yes, that's about right
> (tho you could also do it as (defmacro eieio-declare-slot (name)
> (cl-pushnew name eieio--known-slot-names) nil).
OK, I'll add that to EIEIO.
> My `defclass` solution was meant for use in code that must work with
> older Emacsen and/or older eieio without relying on internals like
> eieio--known-slot-names.
The new CEDET will only target the current master, so I finally don't
have to care about older Emacsen anymore.
-David
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-29 21:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-29 12:39 Fixing "Unknown slot" warnings David Engster
2017-01-29 14:41 ` Stefan Monnier
2017-01-29 15:35 ` David Engster
2017-01-29 17:07 ` Stefan Monnier
2017-01-29 21:26 ` David Engster
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).