On Tue, Oct 12, 2010 at 11:30 AM, Paul Berry <[email protected]> wrote:
> On Mon, Oct 11, 2010 at 11:18 PM, Luke Kanies <[email protected]> wrote:
>>
>> On Oct 9, 2010, at 11:10 AM, Nigel Kersten wrote:
>> > Just so I'm perfectly clear on how this will work with inheritance...
>> > What will happen here with File["foo"] under the proposed model?
>> >
>> >
>> > class nkotb {
>> > File { owner => "root",}
>> > }
>> >
>> > class nsync inherits nkotb {
>> >  file { "foo":
>> >     ...
>> >  }
>> > }
>>
>> I actually don't know how the lexical scoping will affect scoping and
>> inheritance.  I assume that File["foo"] would acquire owner => root; Paul?
>
> Nick and I were debating this question on Friday.  The current behavior in
> 2.6 is that things defined in a base class (whether variables or resource
> defaults) are inherited by the derived class, and that they take precedence
> over dynamic scope.  My preference would be to keep this behavior, so that
> things defined in a base class are inherited by the derived class, and take
> precedence over lexical scope.  So yes, in my vision of how Nigel's example
> would work, File["foo"] would acquire owner => root, just as it does in 2.6.
> To give a more complex example:
> class A {
>   class B {
>     class C { }
>     class D inherits C { }
>     class E inherits D { }
>   }
> }
> My vision of things is that for resources defined inside class E, variable
> references and resource defaults would be looked up in this order:
> - class E
> - class D (inheritance: D is the base of E)
> - class C (inheritance: C is the base of D, which is the base of E)
> - class B (lexical scoping: B contains E)
> - class A (lexical scoping: A contains B, which contains E)
> - toplevel (lexical scoping: A is a toplevel construct, and A contains B,
> which contains E)
> Here's a tricky question: how should Puppet behave when there is a
> combination of inheritance and lexical scoping?  For example:
> class A {
>   class B { }
> }
> class C inherits E {
>   class D inherits B { }
> }
> class E { }
> So, A contains B, which is the base of D.  Should variables and resource
> defaults in A apply to D?  Similarly, E is the base of C, which contains D.
>  Should variables and resource defaults in E apply to D?  If the answer to
> either of these questions is yes, what is the order of precedence?  My
> current answer is "no", just because I'm trying to keep things simple.  But
> I'm open to change my mind if someone can make a case for a different
> behavior :)

ugh. I never do the:

 class A {
  class B { }
 }

construct as I've never been clear on the implications and just keep
all classes in their own files.

I almost feel like that B just being defined inside A shouldn't mean
variables and resource defaults in A apply to B... and that an
inheritance relationship should be required, but I'm unsure.

If we did that, then under Jesse's example that just arrived in my
inbox File["foo"] would be owned by root, but File["bar"] would not.


-- 
nigel

-- 
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.

Reply via email to