Ask Your Question

data types and resource declarations/references

asked 2018-10-31 09:01:54 -0600

jefff gravatar image

I'm trying to get a better grasp of Puppet's language constructs and I'm having difficulty with the following:

Assuming the following is true:

  1. Resource Declarations, since they're an expressions, return a value.
  2. The value returned by a Resource Declaration is a Resource Reference.
  3. A Resource Reference is a data type (and not a value of that type).
  4. The data type Resource Reference is a subtype of Ressource, which itself is a subtype of Data Type.

Now, given that Resource Reference is a TYPE (and not a value), how could it possibly uniquely identify a resource? It would make more sense to me if, to uniquely identify a resource, a VALUE of that type was used instead.

To be more specific here are the 2 excerpts in the documentation that seem to be in opposition (where one stipulates that "Resource Reference" is a type, the other stipulating that "Resource Reference" uniquely identify specific resources.)

For example, a resource declaration -- an expression whose value you might expect would be a resource -- executes a side effect and then produces a resource reference as its value. A resource reference is a data type in this family of data types, rather than a value that has one of those data types.

and this one:

Resource references identify a specific Puppet resource by its type and title.

Thanks for clarifying :)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-10-31 12:05:36 -0600

  1. Only functions _return_ a value.
  2. Expressions _evaluate_ or _resolve_ to a value.
  3. Where have you read Data being a super-type of Resource?
  4. I think you're ignoring the “monism” of a variable. When I declare a variable in C int x; I instruct the computer to reserve some memory. Later I can perform operations on this chunk of memory x = 42; Here I don't ask “how am I able to save a value _in_ a data type?” No, it's just another abstraction layer.
  5. Now, you've already found the paragraph explaining this. A resource declaration adds its data to the catalog. In the Puppet language you can only _implicitly_ create catalog entries. This is done by writing resource declarations. Since all resources have to be unique, you can't just specify another – the same – literal resource declaration (it would trigger the mentioned “side effects” again). No, you have to call it by its name: a reference.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-10-31 08:47:58 -0600

Seen: 98 times

Last updated: Oct 31