On 2014-17-03 10:07, Erik Dalén wrote:
On 14 March 2014 17:00, Henrik Lindberg <henrik.lindb...@cloudsmith.com
<mailto:henrik.lindb...@cloudsmith.com>> wrote:
On 2014-14-03 11:48, Erik Dalén wrote:
Not terribly important, but are there any thoughts on making it
so you
can order variables any way you like in the manifest? They are
immutable
anyway, so these two examples should be equivalent:
$a=1
$b=$a+2
or
$b=$a+2
$a=1
You can put resources in any order you like, so it would make
some sense
to be able to do the same with variables. I guess it could pose some
difficulties with functions reading the scope though, but after
moving
to epp templates there shouldn't be many of those kinds of
functions.
Yes, there has been thoughts about this. It is kind of difficult
though...
$a = [1,2,3]
$b = $a.map |$x| { $c + $x }
$c = $b[1]
and the Journey to Prolog begins... (or to a Spreadsheet like
language...)
While it is true that resources can be placed in any order, it is
important to remember that there are two distinct phases - one that
computes the catalog, and one that applies it. The order among
resources matter if you want to be able to get an attribute set in
one resource while defining another (currently difficult without
Ruby function), but this is available in the future evaluator - e.g.
$mode_of_foo_file = File['foo'][mode]
Currently, we have no guarantees that a function call is side effect
free - it may create new classes, resources and variables.
I am also not sure if making the language completely lazy makes it
any easier for users with the different kind of corner cases (when
to stop iterating if there are loops in the logic, how to understand
what is wrong in those cases, etc.)
What I think we are opening up for in the 4x series is a far better
Catalog model (the end result) thus opening up for interesting
language experiments - say a Clojure or Prolog (on JVM) language
that builds a catalog. If such an implementation turns out to be
fantastic and easy to use / understand, it may take over the world...
Fair enough.
On a bit similar note though, will the new scope implementation be
capable of closures (if you use something like
https://github.com/dalen/puppet-defn to store lambdas in variables)?
>
Yes, the new design makes that possible, but there are corner cases that
requires thought - what should happen if a closure is created in a class
and creates more resources after a class is evaluated etc.
We do not have a ticket logged to add support for closures, not yet at
least. I see this as something that can be defined during the 4x series
of releases as it is not fundamental for 4.0 itself (enough other things
to deal with first).
- henrik
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/lg7q3v%24j5q%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.