bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

Add support for `with` statement [Puppet 4] #200

Closed PierreR closed 6 years ago

PierreR commented 7 years ago
$tenfold = with( $input_number ) |$number| {
  $number * 10
}
bartavelle commented 7 years ago

What is that supposed to do ?

PierreR commented 7 years ago

https://docs.puppet.com/puppet/4.10/function.html#with

bartavelle commented 7 years ago

Oh my, this is a complicated feature again ...

bartavelle commented 6 years ago

I think I implemented with :)

PierreR commented 6 years ago

Cool. It would be nice to support the case when the with statement is an expression:

  $fruit = with("apples", "oranges") |$x, $y| {
    "${x} and ${y}"
  }
ERROR: (swarm.manager.dev) This type of lambda function is not supported yet by language-puppet! with at ./modules/application/manifests/role/swarm/test.pp:4:3
bartavelle commented 6 years ago

Ah right.

bartavelle commented 6 years ago

It would be nice to rewrite it all though.

bartavelle commented 6 years ago

(currently "statements" and "expressions" are distinct things, which was the case before the "future parser")

bartavelle commented 6 years ago

should work now