unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
@ 2019-11-24 15:11 Xu Chunyang
  2019-11-25 17:08 ` bug#38374: " Xu Chunyang
  2019-11-26  1:34 ` bug#38365: " Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Xu Chunyang @ 2019-11-24 15:11 UTC (permalink / raw)
  To: 38365

(info "(eieio) Predicates") mentions

 -- Function: eieio-class-name class
     Return a string of the form ‘#<class myclassname>’ which should
     look similar to other Lisp objects like buffers and processes.
     Printing a class results only in a symbol.

but it is not right, the value is not string at all, it's a symbol

  (defclass my-class () ())
  ;; => my-class

  (eieio-class-name 'my-class)
  ;; => my-class

  (type-of (eieio-class-name 'my-class))
  ;; => symbol

The git master produced the same result as Emacs 26.3. I notice Emacs
24.3's class-name produces the expected result and the function is
replaced by eieio-class-name since 24.4

   (define-obsolete-function-alias 'class-name #'eieio-class-name "24.4")

however, these two functions are different. It seems eieio-class-name
contains a bug, the name suggests its value is a string, but it
returns a symbol.





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

* bug#38374: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-24 15:11 bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect Xu Chunyang
@ 2019-11-25 17:08 ` Xu Chunyang
  2019-11-26  1:34 ` bug#38365: " Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Xu Chunyang @ 2019-11-25 17:08 UTC (permalink / raw)
  To: 38374

I sent this report two days ago, but it seems it is not received
because debbugs.gnu.org was down.

---------- Forwarded message ---------
From: Xu Chunyang <xuchunyang56@gmail.com>
Date: Sun, Nov 24, 2019 at 11:11 PM
Subject: 26.3; The info doc of eieio-class-name is outdated and its
value looks incorrect
To: <bug-gnu-emacs@gnu.org>


(info "(eieio) Predicates") mentions

 -- Function: eieio-class-name class
     Return a string of the form ‘#<class myclassname>’ which should
     look similar to other Lisp objects like buffers and processes.
     Printing a class results only in a symbol.

but it is not right, the value is not string at all, it's a symbol

  (defclass my-class () ())
  ;; => my-class

  (eieio-class-name 'my-class)
  ;; => my-class

  (type-of (eieio-class-name 'my-class))
  ;; => symbol

The git master produced the same result as Emacs 26.3. I notice Emacs
24.3's class-name produces the expected result and the function is
replaced by eieio-class-name since 24.4

   (define-obsolete-function-alias 'class-name #'eieio-class-name "24.4")

however, these two functions are different. It seems eieio-class-name
contains a bug, the name suggests its value is a string, but it
returns a symbol.





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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-24 15:11 bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect Xu Chunyang
  2019-11-25 17:08 ` bug#38374: " Xu Chunyang
@ 2019-11-26  1:34 ` Lars Ingebrigtsen
  2019-11-26 20:44   ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-26  1:34 UTC (permalink / raw)
  To: Xu Chunyang; +Cc: 38365, Stefan Monnier

Xu Chunyang <xuchunyang56@gmail.com> writes:

> (info "(eieio) Predicates") mentions
>
>  -- Function: eieio-class-name class
>      Return a string of the form ‘#<class myclassname>’ which should
>      look similar to other Lisp objects like buffers and processes.
>      Printing a class results only in a symbol.
>
> but it is not right, the value is not string at all, it's a symbol
>
>   (defclass my-class () ())
>   ;; => my-class
>
>   (eieio-class-name 'my-class)
>   ;; => my-class
>
>   (type-of (eieio-class-name 'my-class))
>   ;; => symbol
>
> The git master produced the same result as Emacs 26.3. I notice Emacs
> 24.3's class-name produces the expected result and the function is
> replaced by eieio-class-name since 24.4
>
>    (define-obsolete-function-alias 'class-name #'eieio-class-name "24.4")
>
> however, these two functions are different. It seems eieio-class-name
> contains a bug, the name suggests its value is a string, but it
> returns a symbol.

My guess is that the documentation in the manual just wasn't updated
when this stuff was rewritten back in 2014, and that the return value is
correct.  Stefan?

Currently we have

(defun eieio--class-print-name (class)
  "Return a printed representation of CLASS."
  (format "#<class %s>" (eieio-class-name class)))

(defun eieio-class-name (class)
  "Return a Lisp like symbol name for CLASS."
  (setq class (eieio--class-object class))
  (cl-check-type class eieio--class)
  (eieio--class-name class))
(define-obsolete-function-alias 'class-name #'eieio-class-name "24.4")

but eieio--class-print-name is only used as a fallback in one of the
prin1 cases.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-26  1:34 ` bug#38365: " Lars Ingebrigtsen
@ 2019-11-26 20:44   ` Stefan Monnier
  2019-11-27 12:13     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2019-11-26 20:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38365, Xu Chunyang

>> however, these two functions are different. It seems eieio-class-name
>> contains a bug, the name suggests its value is a string, but it
>> returns a symbol.

FWIW, here a class's name is indeed a symbol: the "not a name" version
would be the class object itself (a struct).


        Stefan






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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-26 20:44   ` Stefan Monnier
@ 2019-11-27 12:13     ` Lars Ingebrigtsen
  2019-11-27 13:52       ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-27 12:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 38365, Xu Chunyang

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

>>> however, these two functions are different. It seems eieio-class-name
>>> contains a bug, the name suggests its value is a string, but it
>>> returns a symbol.
>
> FWIW, here a class's name is indeed a symbol: the "not a name" version
> would be the class object itself (a struct).

I've now updated the manual to say what it really returns now, but it's
not a very useful function.  :-)  (I mean, it just returns its argument.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-27 12:13     ` Lars Ingebrigtsen
@ 2019-11-27 13:52       ` Stefan Monnier
  2019-11-27 13:55         ` Lars Ingebrigtsen
  2019-11-27 13:57         ` Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2019-11-27 13:52 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38365, Xu Chunyang

> I've now updated the manual to say what it really returns now, but it's
> not a very useful function.  :-)  (I mean, it just returns its argument.)

It returns its argument only if its argument was a class name.
It's more useful when its argument is a class object (or when you don't
know which of the two it will be).


        Stefan






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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-27 13:52       ` Stefan Monnier
@ 2019-11-27 13:55         ` Lars Ingebrigtsen
  2019-11-27 13:57         ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-27 13:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 38365, Xu Chunyang

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

>> I've now updated the manual to say what it really returns now, but it's
>> not a very useful function.  :-)  (I mean, it just returns its argument.)
>
> It returns its argument only if its argument was a class name.
> It's more useful when its argument is a class object (or when you don't
> know which of the two it will be).

(eieio-class-name (make-instance 'my-class))
=>
Debugger entered--Lisp error: (wrong-type-argument eieio--class #<my-class my-class-158f4e54cbbc> class)
  signal(wrong-type-argument (eieio--class #<my-class my-class-158f4e54cbbc> class))
  eieio-class-name(#<my-class my-class-158f4e54cbbc>)
  eval((eieio-class-name (make-instance 'my-class)) t)

On the other hand:

(eieio-object-class-name (make-instance 'my-class))
=> my-class

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect
  2019-11-27 13:52       ` Stefan Monnier
  2019-11-27 13:55         ` Lars Ingebrigtsen
@ 2019-11-27 13:57         ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-27 13:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 38365, Xu Chunyang

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

> It returns its argument only if its argument was a class name.
> It's more useful when its argument is a class object (or when you don't
> know which of the two it will be).

Oh, class object, not object.  Never mind.  :-)

(eieio-class-name (eieio--class-object 'my-class))
=> my-class

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2019-11-27 13:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-24 15:11 bug#38365: 26.3; The info doc of eieio-class-name is outdated and its value looks incorrect Xu Chunyang
2019-11-25 17:08 ` bug#38374: " Xu Chunyang
2019-11-26  1:34 ` bug#38365: " Lars Ingebrigtsen
2019-11-26 20:44   ` Stefan Monnier
2019-11-27 12:13     ` Lars Ingebrigtsen
2019-11-27 13:52       ` Stefan Monnier
2019-11-27 13:55         ` Lars Ingebrigtsen
2019-11-27 13:57         ` Lars Ingebrigtsen

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