Issue #5046 has been updated by Jeff McCune.

Dan Bode wrote:
> I disagree with the proposal to drop number 3.

I think we should drop number 3 and move entirely to parameterized class 
declarations where possible.  The convention addresses a number of problems and 
satisfies the use cases below.

> I don't care about redeclaraing parametrized classes, but I do want to be 
> able to mix declarations with include without having to worry about order.
> 
> Use cases:
> 
> classes should be self contained, this requires being able to specify that a 
> class has a dependency on another class. I like the idea of all classes being 
> able to indicate dependencies on other classes with include, but also 
> allowing a single place to override variables.

I consider this use case to be dangerous since the scope and therefore the 
behavior is unpredictable.  Classes should not be included into the scope of 
other classes because they have relationships in the graph.  We need some other 
mechanism other than include to express the relationship of classes.

> Another use case:
> 
> If include is required for variables from a class's scope to be accessible, 
> then you have to be able to mix includes with class declarations. #5074

This use case should also be considered dangerous.  Parameterized classes 
address this use case.  If information stored in variables in class A is needed 
in class B, the information should be presented to the class as an attribute 
parameter, not through accessing variables outside of the class scope and 
requiring A to be nested in B's scope.

This use case also requires a class only be included once in order to guarantee 
scope and behavior.  If we already require a class is only included once to 
satisfy the use case, then a single parameterized class declaration also 
satisfies the use case.

-Jeff


----------------------------------------
Bug #5046: Mixed invocation of parameterized classes leads to order 
dependencies, should be disallowed
https://projects.puppetlabs.com/issues/5046

Author: Paul Berry
Status: Accepted
Priority: Normal
Assignee: 
Category: language
Target version: 2.6.x
Affected Puppet version: 
Keywords: 
Branch: 


When a parameterized class has default values for all of its parameters, it may 
be invoked using either "include" or "class { ... }" notation.  The "include" 
notation is idempotent; the "class { ... }" notation isn't.  As a result, there 
is an order dependency.  This works:

<pre>
class foo($param = defaultvalue) {
  notify { $param: }
}

class { foo: param => value }
include foo
</pre>

But this produces an error:

<pre>
class foo($param = defaultvalue) {
  notify { $param: }
}

include foo
class { foo: param => value }
</pre>

In large manifests, it is not always obvious (or even well-defined) what order 
statements will be executed in.  To avoid user confusion, I think it would be 
preferable if both these examples produced an error message saying something 
like "class foo already invoked using 'class { ... }' syntax, cannot also 
invoke using 'include'".


-- 
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://projects.puppetlabs.com/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.

Reply via email to