[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

default values of flavor instance vars

Given this form:

(defflavor foo
	((a 1)
	 (b 2)
	 (c 3))

Is there a way to programmatically determine
the default values for the instance variables of foo?


1. Simple answer


  (flavor:find-flavor 'foo))

;--> ((A 1) (B 2) (C 3))

2. Complications

Suppose I define my-foo as
(defflavor my-foo
  (:default-init-plist :a 5))

(flavor:flavor-default-init-get 'my-foo :a)
;---> 5

If I do:
(compose-flavor-methods my-foo)
then there are some more possibilities, e.g.

  (flavor::flavor-template-instance (flavor:find-flavor 'my-foo)))
;---> 5

(foo-a (flavor::flavor-template-instance (flavor:find-flavor 'my-foo)))
;---> 5

With the exception of flavor:flavor-default-init-get which is documented
(vol 2A, pp 418) all the other approaches are undocumented, so I
wouldn't recommend them - an additional reason being that you need to know
and assume A LOT about the state of flavor compositions, inheritance,
default-init-plists, etc. -.

	I myself will be waiting for a more satisfactory answer.