Google Groupes

Lexical Scope: How does it work?


Nick Moffitt 17 nov. 2010 04:27
Envoyé au groupe : Puppet Users
Let me start by saying that I am a fan of lexical scoping as a way of
increasing confidence in your execution models.  I am hoping to move
from the now thoroughly debunked "wackyscope" model that used to plague
many programming languages over to proper lexical scoping in my puppet
configs.  I'm just having trouble finding documentation of how this
works for puppet.

I understand that a lexically-scoped puppet config would need to use
parameterized classes.  What I'm not clear on is how facts would be
scoped.  Are they some top-level that needs to be passed into nodes?
Are they present in a node's scope?  What if it inherits?  Do I need to
pass these facts in as parameters as well? (I hope so).

The only documentation I can find at all for lexical scoping in puppet
is in puppet.conf(5):

       lexical +++++++

       Whether to use lexical scoping (vs. dynamic).

       �   Default: false

That's a bit thin.  I assume this is only needed on the master, of
course.

--
"These people program the way Victorians dress.
It takes two hours and three assistants to put on
your clothes, and you have to change before dinner.
But everything is modular."    -- Miles Nordin, on PAM