[noctool-devel] New CLUSTER macro! And a WITH-FORMAT to go with it!
Ingvar
ingvar at hexapodia.net
Thu Feb 19 08:43:35 UTC 2009
The cluster config macro has had some problems, in that it can do one thing
(and one thing only), normally the name, numbered in the normal style.
So, in a fit of "let's make this better and trivially nestable", I cooked up a
new cluster macro. It's subtly different from the old one, but configs that
use the non-complicated version of the old one should work identically under
the new one.
(cluster (<fmt-string> <low> <high> &key c-fmt name counter)
<stanza to be repeated>)
:name <name> specifys a symbol to be replaced, instead of the default NAME
:c-fmt decides if a conversion from C-style format to lisp style format
should happen (still defaults to true, but by happy co-incidence, the
~-style lisp arguments are NOT mangled by the C-style conversion, strictly
speaking a bug, but maybe not worth fixing at the moment)
:counter is NEW, this specifies a counter to be sequentially set from low to
high in the expansion. This defaults to a gensym, so cannot be used without
specifying it.
(with-format ((sym1 fmt1 vars1... ) (sym2 fmt2 vars2 ...))
<config stanza>)
Like LET, only, eh, thing...
I also cooked up an example (in test-files/nested-cluster.cfg):
(cluster ("" 1 2 :counter a)
(cluster ("" 1 2 :counter b)
(with-format ((name "node~d-cpu~d" a b)
(ip-addr "172.23.~d.~d" a b))
(machine name linux-host
(user "testuser")
(ip ip-addr)))))
Somewhat annoyingly, when I test-ran this I noticed that our post-creation
clean-up for EQUIPMENT objects is a bit... aggressive. When created from a
config stanza, the ONLY thing specified is the name, all else is (eventually)
done with (setf *config-object* 'slot-to-set <value>) or pushing things onto
the monitor list, as it were.
While the clean-up done in the initialize-after method is good, I am wondering
if it may be worth creating a new "post-config-cleanup" GF and move the relevant
clean-up bits to there, as I actually had to re-define the :after method t do
nothing to be able to run my tests (it's vastly easier to use example names to
see if things work or not, when one doesn't actually have a cluster at hand).
//Ingvar
More information about the Noctool-devel
mailing list