all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Gnu ELPA cl-generic bug?
@ 2018-11-28  0:17 Stephen Leake
  2018-11-28  2:47 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Leake @ 2018-11-28  0:17 UTC (permalink / raw)
  To: emacs-devel

I'm trying to use the Gnu ELPA package cl-generic to support
cl-defmethod in Emacs 24.5.

I have this set of definitions:

(cl-defstruct wisi-parser
  ;; Separate lists for lexer and parse errors, because lexer errors
  ;; must be repaired first, before parse errors can be repaired. And
  ;; they have different structures.
  lexer-errors
  ;; list of wisi--lexer-errors from last parse.  Can be more than one if
  ;; lexer supports error recovery.
  parse-errors
  ;; List of wisi--parse-errors from last parse. Can be more than one if
  ;; parser supports error recovery.
)

(cl-defgeneric wisi-parse-kill ((parser wisi-parser))
  "Kill any external process associated with parser.")


(cl-defstruct (wisi-elisp-parser (:include wisi-parser))
  actions
  gotos
  next-token
  )

(cl-defmethod wisi-parse-kill ((_parser wisi-elisp-parser))
  nil)


(cl-defstruct (wisi-process--parser (:include wisi-parser))
 ...
 )
 
(cl-defmethod wisi-parse-kill ((parser wisi-process--parser))
  (when (process-live-p (wisi-process--parser-process parser))
    (process-send-string (wisi-process--parser-process parser) wisi-process-parse-quit-cmd)
    (sit-for 1.0)
    (when (process-live-p (wisi-process--parser-process parser))
      (kill-process (wisi-process--parser-process parser)))
    )
  (setf (wisi-process--parser-busy parser) nil))


Whenever one of these 'cl-defmethod' forms is encountered, the byte
compiler issues an error:

Error: Unknown class type wisi-elisp-parser in method parameters

The ELPA package cl-generic defines cl-defgeneric and cl-defmethod,
using eieio defgeneric and defmethod. It does _not_ define cl-defstuct;
that has its normal definition that does not use eieio.

So I suspect the problem is that the eieio class 'wisi-elisp-parser' is
never declared, because 'cl-defstruct' does not call eieio defclass.

Is there a simple fix for this?

-- 
-- Stephe



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

* Re: Gnu ELPA cl-generic bug?
  2018-11-28  0:17 Gnu ELPA cl-generic bug? Stephen Leake
@ 2018-11-28  2:47 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2018-11-28  2:47 UTC (permalink / raw)
  To: emacs-devel

> I'm trying to use the Gnu ELPA package cl-generic to support
> cl-defmethod in Emacs 24.5.
[...]
> (cl-defstruct wisi-parser
[...]
> (cl-defgeneric wisi-parse-kill ((parser wisi-parser))

That won't work: the GNU ELPA package only provides the common subset
between the old EIEIO defmethod and the cl-generic cl-defmethod.
More specifically, you can only dispatch on the first arg and only on
EIEIO classes, not defstructs, nor built-in types.

IOW, it only lets you use the cl-generic syntax instead of the old EIEIO
syntax.


        Stefan




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

end of thread, other threads:[~2018-11-28  2:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-28  0:17 Gnu ELPA cl-generic bug? Stephen Leake
2018-11-28  2:47 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.