On Apr 18, 2012, at 3:20 PM, Jo Rhett wrote:

> On Apr 17, 2012, at 9:00 AM, Andrew Parker wrote:
>> Has anyone seen something where a manifest used $::var in order to *not* get 
>> the value of $var that is overridden in a node?
> 
> Uh… I use it extensively.

Ah, interesting. Could you provide some examples of what you use it for?

> 
>>> At the moment (and under the new regime)
>>> 
>>>   $var = "top scope"
>>>   node default { 
>>>     $var = "node"
>>>     include foo
>>>   }
>>>   class foo {
>>>     notify { "which is it?": message => $var }
>>>   }
>>> 
>>> $var is going to evaluate to "node". If you change that to $::var, then 
>>> you'll end up with "top scope". This doesn't seem right
> 
> Why not? This makes perfect sense to me.  Unless I am totally 
> misunderstanding something, I truly can't fathom why this isn't bad.
> 

The bad thing (under the new system) is that node is a special citizen that 
gets to have dynamic scoping, but nothing else does. 

If node was not its own scope and instead was just part of top scope, then the 
rules for where a variable comes from turns into "in the class, the parent(s), 
or the topscope".

If node is its own scope that is given special dynamic lookup status, then your 
rules are "in the class, the parent(s), whatever node included the class".

In both cases there is the additional complication of node inheritance which 
makes it even harder to figure out what value you are actually going to end up 
with.

> In fact, I'd prefer stricter lexical scoping rather than vaguer. I believe 
> that the current situation is what confuses everyone, and that if referencing 
> something out of scope was ALWAYS explicit that would be preferred.  I'd also 
> prefer tighter scoping around each node -- I could simplify a lot of code if 
> this worked better, such that I could use node variables within parameterized 
> classes easily, always being set for the node currently being operated on.
> 

Do you mean having no nesting of scopes at all (i.e. everything is local and 
there is no lookup outside of the scope)? That would mean a lot more verbose 
manifests but is a possible option. 

Could you elaborate on what you mean by tighter scoping around the node? An 
example of what that might look like, perhaps?

> -- 
> Jo Rhett
> Net Consonance : consonant endings by net philanthropy, open source and other 
> randomness
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to puppet-dev@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to