[hunchentoot-devel] Subclassing ACCEPTOR
Hans Hübner
hans.huebner at gmail.com
Mon Dec 12 14:54:18 UTC 2011
Sebastian,
the acceptor class has a :default-initargs clause, so the :initform
that you've provided is never being looked at. Use a
:default-initargs in your vhost class to override the inherited :name
initarg.
-Hans
On Mon, Dec 12, 2011 at 3:07 PM, Sebastian Tennant
<sebyte at smolny.plus.com> wrote:
> Hi list,
>
> (make-package :vhost :use '(:common-lisp))
> ;;; => #<PACKAGE "VHOST">
>
> (in-package :vhost)
>
> (defclass vhost (tbnl:acceptor)
> ((tbnl::name
> :initform
> (error "Please give this VHOST a meaningful name."))))
> ;;; => #<STANDARD-CLASS VHOST>
>
> (describe 'vhost)
> ;;; => VHOST::VHOST
> ;;; [symbol]
> ;;;
> ;;; VHOST names the standard-class #<STANDARD-CLASS VHOST>:
> ;;; Class precedence-list: VHOST, HUNCHENTOOT:ACCEPTOR, STANDARD-OBJECT,
> ;;; SB-PCL::SLOT-OBJECT, T
> ;;; Direct superclasses: HUNCHENTOOT:ACCEPTOR
> ;;; No subclasses.
> ;;; Direct slots:
> ;;; HUNCHENTOOT::NAME
> ;;; Initform: (ERROR "A virtual host must have a meaningful name.")
>
> (defvar *vhost1* (make-instance 'vhost))
> ;;; => *VHOST1* <--- WHY NO ERROR ???
>
> (describe *vhost1*)
> ;;; => #<VHOST (host *, port 80)>
> ;;; [standard-object]
> ;;;
> ;;; Slots with :INSTANCE allocation:
> ;;; PORT = 80
> ;;; ADDRESS = NIL
> ;;; NAME = #:G1150 <--- this is what I want to prevent
> ;;; [...]
>
> Practical Common Lisp - page 214:
>
> "... if multiple classes specify an initform the new class uses the one from
> the most specific class. This allows a subclass to specify a different
> default value than the one it would otherwise inherit."
>
> What am I doing wrong here?
>
> Sebastian
> --
> Emacs' AlsaPlayer - Music Without Jolts
> Lightweight, full-featured and mindful of your idyllic happiness.
> http://home.gna.org/eap
>
>
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel
More information about the Tbnl-devel
mailing list