On Feb 23, 2010, at 3:50 PM, Markus Roberts wrote:
A few more thoughts/questions and a potential option:
* Should hash assignments be by reference or by value? In other
words, what should this do:
$h1 = { a => b }
$h2 = $h1
:
$h2[x] = y
notice $h1
Should the hash in $h2 be a copy of the hash in $h1, or are they
the same object?
Seems like reference is the right answer.
* Is array really the right consistency model? For example, one
might argue that $h should be {content=>bar, mode=>0777} throughout
the following:
class c0 {
file {'/tmp/foo': content => 'bar' }
$h = { contents => bar}
}
class c1 inherits c0 {
notice "2: h = $h"
File['/tmp/foo'] { mode => 0777 }
$h += { mode => 0777 }
notice "3: h = $h"
}
notice "1: h = $h"
include c1
notice "4: h = $h"
-----------------------------------------------------------------------------------------------------------------------
To get concrete, what do you think of the following semantics:
* $h1 in the first example above would be distinct from $h2
(assignment is a copy).
* The value of a hash is the same at all points in all scopes in
which the hash can be seen, and reflects all contributions.
* h += { k1 => v1, k2 => v2...} is syntactic sugar for h[k1]=v1;
h[k2]=v2; ...
* Any number of h[kx] =... assignments are allowed each scope, but
only one per key globally
* Hash keys are constrained in some way:
* they must be literal strings
* or they may not depend on values from a hash
* or they may not depend on values in the same hash
IMO, this has gotten more complicated than I even feel comfortable
making a decision about. I don't know if the current scope semantics
of Puppet apply well to hashes, and maybe we need to change the
semantics, or provide new ones, so this is less confusing. Is there a
way to frame this so it has few edge cases?
--
Finn's Law:
Uncertainty is the final test of innovation.
---------------------------------------------------------------------
Luke Kanies -|- http://reductivelabs.com -|- +1(615)594-8199
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.