[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))
()
:initable-instance-variables
:writable-instance-variables
:abstract-flavor)
Is there a way to programmatically determine
the default values for the instance variables of foo?
----------------
1. Simple answer
Evaluating
(flavor::flavor-instance-variable-initializations
(flavor:find-flavor 'foo))
;--> ((A 1) (B 2) (C 3))
2. Complications
Suppose I define my-foo as
(defflavor my-foo
()
(foo)
(:default-init-plist :a 5))
Then,
(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.
(symbol-value-in-instance
(flavor::flavor-template-instance (flavor:find-flavor 'my-foo)))
;---> 5
or,
(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.
Theo
------------------