unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to silence "Unknown slot" compiler warnings?
@ 2016-02-15 20:15 Vitalie Spinu
  2016-02-15 21:13 ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Vitalie Spinu @ 2016-02-15 20:15 UTC (permalink / raw)
  To: emacs-devel


Hi,

I am getting loads of "Unknown slot" messages during compilation of my
package. Why are they happening and how can I silence them?

My use case is simple, define a class, create an object of that class and store
it in buffer local variable. Now, all instances of oref, oset and macros that
operate on those objects generate this warning.

Thanks,

  Vitalie


GNU Emacs 25.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7) of 2016-01-21




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-15 20:15 How to silence "Unknown slot" compiler warnings? Vitalie Spinu
@ 2016-02-15 21:13 ` Stephen Leake
  2016-02-16  0:22   ` Vitalie Spinu
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2016-02-15 21:13 UTC (permalink / raw)
  To: Vitalie Spinu; +Cc: emacs-devel

Vitalie Spinu <spinuvit@gmail.com> writes:

> I am getting loads of "Unknown slot" messages during compilation of my
> package. Why are they happening and how can I silence them?

They happen because the byte compiler is pickier than you are about how
to spell the names of the slots.

> My use case is simple, define a class, create an object of that class and store
> it in buffer local variable. Now, all instances of oref, oset and macros that
> operate on those objects generate this warning.

Please post the code (or at least some of it), and the warnings.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-15 21:13 ` Stephen Leake
@ 2016-02-16  0:22   ` Vitalie Spinu
  2016-02-16  5:38     ` Eric Abrahamsen
  2016-02-21  2:05     ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Vitalie Spinu @ 2016-02-16  0:22 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel


>> On Mon, Feb 15 2016 15:13, Stephen Leake wrote:

> Please post the code (or at least some of it), and the warnings.

It's here:

 https://github.com/vspinu/polymode/blob/master/polymode-classes.el

I am always using :initarg with keywords because I want to emphasise slot names
in main code:

  (defclass pm-polymode (pm-root) 
  ((hostmode
    :initarg :hostmode


  Vitalie





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-16  0:22   ` Vitalie Spinu
@ 2016-02-16  5:38     ` Eric Abrahamsen
       [not found]       ` <871t8dase0.fsf@gmail.com>
  2016-02-21  2:05     ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2016-02-16  5:38 UTC (permalink / raw)
  To: emacs-devel

Vitalie Spinu <spinuvit@gmail.com> writes:

>>> On Mon, Feb 15 2016 15:13, Stephen Leake wrote:
>
>> Please post the code (or at least some of it), and the warnings.
>
> It's here:
>
>  https://github.com/vspinu/polymode/blob/master/polymode-classes.el
>
> I am always using :initarg with keywords because I want to emphasise slot names
> in main code:
>
>   (defclass pm-polymode (pm-root) 
>   ((hostmode
>     :initarg :hostmode
>
>
>   Vitalie

You're using oref/oset with arguments as :tags, but the slot name should
just be a non-quoted, non-tag macro argument.

E




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
       [not found]       ` <871t8dase0.fsf@gmail.com>
@ 2016-02-16 14:15         ` Eric Abrahamsen
  2016-02-16 14:51           ` Stephen Leake
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2016-02-16 14:15 UTC (permalink / raw)
  To: emacs-devel


On 02/16/16 10:58 AM, Vitalie Spinu wrote:
>>> On Tue, Feb 16 2016 13:38, Eric Abrahamsen wrote:
>
>> You're using oref/oset with arguments as :tags, but the slot name should just
>> be a non-quoted, non-tag macro argument.
>
> What is this restriction for?
>
> That's the whole point of :initarg AFAIC. I need to use keywords to enhance
> readability of the code. There quite a few slots in my package and I want to
> distinguish then from local and global vars.

Initargs are still tags and only tags. But slot reference is only a
"naked" slot name (with oref/oset), or else a quoted symbol (with
eieio-{oref,oset}, or slot-value and set-slot-value). oref and oset are
just thin wrappers around the eieio-* versions.

I can't say why! I'm also a little uncomfortable about the "naked"
versions, and for the same reason -- my brain keeps seeing them as
variables.

> So I am afraid dropping keywords is not an option for me. Is there a way to
> selectively force shut compiler warnings in emacs?

That I couldn't tell you.

(Don't forget to follow-up to the list.)




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-16 14:15         ` Eric Abrahamsen
@ 2016-02-16 14:51           ` Stephen Leake
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Leake @ 2016-02-16 14:51 UTC (permalink / raw)
  To: emacs-devel

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> On 02/16/16 10:58 AM, Vitalie Spinu wrote:
>>>> On Tue, Feb 16 2016 13:38, Eric Abrahamsen wrote:
>>
>>> You're using oref/oset with arguments as :tags, but the slot name should just
>>> be a non-quoted, non-tag macro argument.
>>
>> What is this restriction for?
>>
>> That's the whole point of :initarg AFAIC. I need to use keywords to enhance
>> readability of the code. There quite a few slots in my package and I want to
>> distinguish then from local and global vars.
>
> Initargs are still tags and only tags. But slot reference is only a
> "naked" slot name (with oref/oset), or else a quoted symbol (with
> eieio-{oref,oset}, or slot-value and set-slot-value). oref and oset are
> just thin wrappers around the eieio-* versions.
>
> I can't say why! I'm also a little uncomfortable about the "naked"
> versions, and for the same reason -- my brain keeps seeing them as
> variables.

More importantly, it's a change from Emacs 24, that breaks a lot of
existing code.

Does this change make eieio consistent with some standard?

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-16  0:22   ` Vitalie Spinu
  2016-02-16  5:38     ` Eric Abrahamsen
@ 2016-02-21  2:05     ` Stefan Monnier
  2016-02-21  4:13       ` Eric Abrahamsen
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2016-02-21  2:05 UTC (permalink / raw)
  To: emacs-devel

> I am always using :initarg with keywords because I want to emphasise
> slot names in main code:

>   (defclass pm-polymode (pm-root) 
>   ((hostmode
>     :initarg :hostmode

:hostmode is not a slot name, it's an initarg name.  EIEIO is mostly an
implementation of CLOS, but for some reason it decided to allow you to
say (slot-value x :hostmode) instead of (slot-value x 'hostmode).

The two are equivalent, except that:
- (slot-value x :hostmode) is not accepted by CLOS.
- (slot-value x :hostmode) is slower.

> I can't say why! I'm also a little uncomfortable about the "naked"
> versions, and for the same reason -- my brain keeps seeing them as
> variables.

The "naked" version only shows up with (oref x hostmode) which is an
EIEIO-only macro which is equivalent to (slot-value x 'hostmode).
As you can see, the (slot-value x 'hostmode) version doesn't suffer from
this problem (and additionally it's part of CLOS), so I encourage you to
use that instead.
EIEIO can't take advantage of the compile-time-knowledge of `hostmode'
to speed up the slot access anyway, so you might as well use `slot-value'.

Both `oref' and `slot-value' are "namespace unclean" (they don't have
any kind of "package prefix"), but `oref' is a much more likely
candidate to obsolescence because `slot-value' at least has the argument
that it's a standard CLOS name.


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to silence "Unknown slot" compiler warnings?
  2016-02-21  2:05     ` Stefan Monnier
@ 2016-02-21  4:13       ` Eric Abrahamsen
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2016-02-21  4:13 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

[...]

>> I can't say why! I'm also a little uncomfortable about the "naked"
>> versions, and for the same reason -- my brain keeps seeing them as
>> variables.
>
> The "naked" version only shows up with (oref x hostmode) which is an
> EIEIO-only macro which is equivalent to (slot-value x 'hostmode).
> As you can see, the (slot-value x 'hostmode) version doesn't suffer from
> this problem (and additionally it's part of CLOS), so I encourage you to
> use that instead.
> EIEIO can't take advantage of the compile-time-knowledge of `hostmode'
> to speed up the slot access anyway, so you might as well use `slot-value'.

Thanks! It's good to have a clear answer to that.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-21  4:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 20:15 How to silence "Unknown slot" compiler warnings? Vitalie Spinu
2016-02-15 21:13 ` Stephen Leake
2016-02-16  0:22   ` Vitalie Spinu
2016-02-16  5:38     ` Eric Abrahamsen
     [not found]       ` <871t8dase0.fsf@gmail.com>
2016-02-16 14:15         ` Eric Abrahamsen
2016-02-16 14:51           ` Stephen Leake
2016-02-21  2:05     ` Stefan Monnier
2016-02-21  4:13       ` Eric Abrahamsen

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).