Forum: CFEngine Help
Subject: Re: Intended behavior for vars in parametrized bundle?
Author: jblaine
Link to topic: https://cfengine.com/forum/read.php?3,23611,23612#msg-23612

sauer Wrote:
-------------------------------------------------------
> Say I have a bundle which takes a parameter, and
> then I refer to that bundle a nmber of times with
> different parameters.  Is there an expected state
> for variables within that bundle?  In other words,
> which iteration of a bundle does a scoped
> reference, well, refer to?  For an untested
> example:
> 
> 
> bundle agent master {
> vars:
>   "pie" slist => {"apple", "cherry",
> "huckleberry"};
> methods:
>   "blaster" usebundle => blaster("$(pie)");
> reports:
>   "We were left with '$(blaster.f)' in blaster's
> f";
> }
> bundle agent blaster (f){
> vars:
>   "thisflavor" string => "$(f)";
> }
> 
> 
> 
> Yeah, I suppose I could emperically figure out
> what's going on, but someone has to have thought
> about this before, so I'm wondering what the
> decision was.  I'd feel better if I was validating
> that a design decision operates as expected,
> rather than guessing at how things are probably
> supposed to work.  And posting up here's easier
> than reading the full source code (although that's
> certainly on my list of things to do). :)

Pure speculation, but slists are always iterated in order.  I don't see how 
your report would ever state anything other than being left with "huckleberry"

You shouldn't have to empirically determine such a thing through trial and 
error.  It should be documented.

That said, I've not written 3 consecutive mildly abstracted lines of CF3 code 
in the last 2 weeks that has done anything remotely close to what is expected 
according to the documentation.  I'm starting to believe the majority (not all) 
of people using CF3 have no real ideas (or effort) toward writing cleanly 
abstracted and shareable bundles -- a feat the language espouses to conquer 
with ease.

> Or is this just something that should be avoided
> due to its somewhat sketchy nature, and it's left
> at that?

There should be nothing sketchy about it, in theory.  If it's valid language 
syntax, it should be documented.  Nobody learning any language worth anybody's 
time has had to read the source code to determine expected behavior.  This has 
had 17 years to come to fruition, so surely the basics of the state/scope 
should be easily pointed to by the authors.

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to