Re: Parent's slot overwriting

"Eric M. Ludlam" <[email protected]> Mon, 07 Jun 2010 08:03:00 -0400
Newsgroups gmane.emacs.eieio
Message-ID <[email protected]>
Hi Frank,

The case you identified below that throws an error is the right 
behavior.  If the :type slot can change, then you can't reliably 
(call-next-method) in the subclass method since the parent's method 
would be expecting data of a different type.

In this case, I think the doc needs updating.

Thanks
Eric

On 06/04/2010 02:30 PM, Frank wrote:
> Hi,
>
> Please try this.  I get an error if I try to evaluate the child class.
>
> Regards,
> Frank
>
> (require 'eieio)
>
> (defclass foo ()
>    ((field :type string)))
>
> (defclass bar ()
>    ((field :type wholenum)))
>
> ;; I get an error here.
> ;; Apparently there's a typecheck done for field.
> ;;
> ;; The documentation says:
> ;;   If the new class has a slot with the same name as the parent,
> ;;   the new slot overrides the parent's slot.
> ;;
> ;; Is this supposed to throw an error in this case?
> (defclass child (bar foo)
>    ((field :type vector)))
>
> ;; This evaluates fine.
> ;; (defclass child (bar foo)
> ;;   ((field :type wholenum)))  ;; bar's field type matches child's
> field type

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo