[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EIEIO: how to validate a new instance?
From: |
Raffaele Ricciardi |
Subject: |
EIEIO: how to validate a new instance? |
Date: |
Thu, 02 Aug 2012 17:29:42 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
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.
- EIEIO: how to validate a new instance?,
Raffaele Ricciardi <=