Bug #9849
Functions in puppet, or resources that return an lvalue
| Status: | Needs More Information | Start date: | 10/01/2011 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | - | % Done: | 0% | |
| Category: | language | |||
| Target version: | - | |||
| Affected Puppet version: | Branch: | |||
| Keywords: | puppet resources functions lvalue | |||
Description
Yeah, you could just use Ruby, but not all of my colleagues know ruby, but are pretty good with puppet. It would be useful to do this:
define foo()
{
$lvalue = $name * 4
}
$value = foo { 8: }
On a side note, referencing member-values of resources would also be useful. eg.:
foo { 'bar': message => 'hello world' }
bar { 'sdalfkjslkj': message => Foo['bar'].message }
History
#1
Updated by Josh Cooper over 1 year ago
- Status changed from Unreviewed to Needs More Information
Hi Giles,
Giles Constant wrote:
Yeah, you could just use Ruby, but not all of my colleagues know ruby, but are pretty good with puppet. It would be useful to do this:
define foo() { $lvalue = $name * 4 } $value = foo { 8: }
I’m having trouble understanding what this example is trying to show. Is there a particular use case where having this capability would be useful?
On a side note, referencing member-values of resources would also be useful. eg.:
foo { 'bar': message => 'hello world' } bar { 'sdalfkjslkj': message => Foo['bar'].message }
This is something that can be accomplished using variables, so I’m not sure what additional benefit this would provide?
#2
Updated by Henrik Lindberg 9 months ago
The first suggestion looks like a request to implement named functions.
function foo($x) { return $x * 8 }
by reuse of the resource define keyword. This I like, but not by using the same keyword as for definitions.
The second, I like, because it is cleaner that using variables.