On 09/02/10 19:03, Markus Roberts wrote:
>> Hmm, another alternative would be to hook an ephemeral scope hierarchy
>> to the current scope; evaluate_match would then spawn a new ephemeral
>> scope which would "alias" the previous one in the same scope. That would
>> be the cleanest solution.
> 
> It might also violate the principle of least surprise.  What would you expect:
> 
> $var = "matchagain"
> case $var {
>  /match/: {
>     notice($0)
>     if $var =~ /matchagain/ {
>       notice($0)
>     }
>     notice($0)
>   }
> }
> 
> to produce?

clearly:
match
matchagain
match

Explanation:
/match/ -> creates an ephemeral scope containing $0 == match
=~ -> creates a child ephemeral scope containing $0 == matchagain
out of if -> pops the last child ephemeral scope
last notice sees match

But unfortunately the following will not work

case $var {
  /match/: {
     if $var =~ /matchagain/ and $var =~ /aslomatch/ {
       notice($0)
     }
     notice($0)
  }
}

Because both =~ will spawn a new ephemeral scope, but out-of-if might
not kown how many ephemeral scope were created, except if it keeps the
number somewhere, which looks ugly (ie keeping state out of the scope).

Any better idea?
-- 
Brice Figureau
My Blog: http://www.masterzen.fr/

-- 
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