all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: EIEIO: how to validate a new instance?
  2012-08-02 16:29 EIEIO: how to validate a new instance? Raffaele Ricciardi
@ 2012-08-02 15:46 ` David Engster
  2012-08-02 16:40 ` Raffaele Ricciardi
  1 sibling, 0 replies; 3+ messages in thread
From: David Engster @ 2012-08-02 15:46 UTC (permalink / raw
  To: Raffaele Ricciardi; +Cc: help-gnu-emacs

Raffaele Ricciardi writes:
> but I can't find the proper incantation to make it work (I even
> managed to make Emacs crash).

Even if your initial problem is solved, please define "crash". If you
managed to provoke a segmentation fault through Emacs Lisp, then this is
a bug.

-David



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

* EIEIO: how to validate a new instance?
@ 2012-08-02 16:29 Raffaele Ricciardi
  2012-08-02 15:46 ` David Engster
  2012-08-02 16:40 ` Raffaele Ricciardi
  0 siblings, 2 replies; 3+ messages in thread
From: Raffaele Ricciardi @ 2012-08-02 16:29 UTC (permalink / raw
  To: help-gnu-emacs

Hello everyone,

I need to create a new EIEIO object, but not all values are acceptable as
initargs.  My understanding is that I should use initialize-instance for 
checks,
but I can't find the proper incantation to make it work (I even managed 
to make
Emacs crash).

Here is a sample code:

(require 'eieio)

(defclass my-class ()
   ((x :initarg :x
	   :type string )))

So far, so good.  I can instantiate my class:

(setq ^c (my-class "my-class" :x "x"))

Here is one of my attempts at initialize-instance:

(defun initialize-instance ((^c my-class) ^args) nil)

It doesn't work: now I can't instantiate my class anymore:

(setq ^c (my-class "my-class" :x "x"))

Fails with:

 > Debugger entered--Lisp error: (invalid-function (lambda ((^y 
my-class) ^args)
nil))
 > initialize-instance([object my-class "my-class" unbound] (:x "x")) Any
help?  Thank you.


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

* Re: EIEIO: how to validate a new instance?
  2012-08-02 16:29 EIEIO: how to validate a new instance? Raffaele Ricciardi
  2012-08-02 15:46 ` David Engster
@ 2012-08-02 16:40 ` Raffaele Ricciardi
  1 sibling, 0 replies; 3+ messages in thread
From: Raffaele Ricciardi @ 2012-08-02 16:40 UTC (permalink / raw
  To: help-gnu-emacs

Ouch!  I had to define initialize-instance with defmethod, not defun.

Thank you all for the attention.


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

end of thread, other threads:[~2012-08-02 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 16:29 EIEIO: how to validate a new instance? Raffaele Ricciardi
2012-08-02 15:46 ` David Engster
2012-08-02 16:40 ` Raffaele Ricciardi

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.