On Aug 17, 2010, at 1:39 PM, Jesse A Wolfe wrote:

Doesn't this convert classes, definitions, et al from parse-time constructs into compile-time constructs?
Not exactly. We've added a new phase.

Parsing is now a side-effect-free function from .pp files to AST trees. After that, in the new phase, we create the hostclass and definition objects *from the ASTs*. After that we compile the rest of the AST. This process has access to the full TypeCollection from the start, same as it had before.

Having parsing be a function from .pp file to AST tree means that we can be much smarter about caching, and staleness. It might improve our memory footprint, because the AST interpretation of a .pp file doesn't change between environments. It also gives us the power to query .pp files about what hostclasses they define, without involving the larger mechanisms of the TypeCollection or the Environment.

It seems to me that this is basically the "Multi-pass compiler" pattern.

So it looks like we now just read the code in, convert to AST, and immediately create the types from the AST - it's not like we create a single AST and then find all of the AST Type instances and instantiate them. When you mentioned phases, my concern was initially that the AST->Type conversion was triggered by a compile or something, but it looks like it's triggered by type loading, like it used to be.

That is, with this patch in place can I still get a list of classes after parsing but not compiling?

Yes. There's just one new method call to get the list of classes. To put it into the multi-pass metaphor, you need only invoke the first pass of the compiler.


Looks like asking questions from puppetmasterd via the API should still work then.

--
The Number 1 Sign You Have Nothing to Do at Work...
    The 4th Division of Paperclips has overrun the Pushpin Infantry
    and General White-Out has called for a new skirmish.
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199

--
You received this message because you are subscribed to the Google Groups "Puppet 
Developers" 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-dev?hl=en.

Reply via email to