Issue #2957 has been updated by Luke Kanies. Target version changed from Rowlf to Statler
No way this is happening in rowlf. ---------------------------------------- Feature #2957: Classes should support an 'extends' functionality http://projects.reductivelabs.com/issues/2957 Author: Luke Kanies Status: Accepted Priority: Normal Assigned to: Category: language Target version: Statler Affected version: 0.25.1 Keywords: Branch: Current inheritance behaviour doesn't cover enough functionality. It's quite often that people want to override things other than resources in a subclass, but it doesn't work. E.g.: <pre> class base { $var = foo file { "/m": content => $var } } class sub inherits base { $var = other } </pre> This doesn't work for two reasons: First, because the resource is created with the base class's value before the sub class sets its variable. This will be fixed in #2596. Second, the base and subclass have separate scopes, so the resource defined in the base class knows absolutely nothing about the subclass's variable. I propose we add a new kind of class relationship, called 'extension'. It's very similar to inheritance (and likely will entirely replace it at some point), except that the entire class hierarchy shares a single scope. Thus, in the above code, the subclass's $var setting would actually replace the base class's setting. This behaviour would require that all things that affect scope -- variable setting, defaults, and maybe more -- would need to retain source information, like resource parameters do, so we could meet the same inheritance rules we have now. For instance, the following should be an error: <pre> class base { $var = foo file { "/m": content => $var } } class sub1 extends base { $var = other } class sub2 extends base { $var = yay } include sub1, sub2 </pre> But this would not: <pre> class base { $var = foo file { "/m": content => $var } } class sub1 extends base { $var = other } class sub2 extends sub1 { $var = yay } include sub1, sub2 </pre> This works because sub2 is a child of sub1, rather than a peer, so it can override its parent. It's currently unresolved whether extension and inheritance can be used in the same class hierarchy. Instinctively, it seems like they could, but I think that would be pretty confusing. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://reductivelabs.com/redmine/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" 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-bugs?hl=en.
