unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* 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

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

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