I tend to avoid += since it's a "magic" edge case in variable scope.

If all of my code takes the strict view that variables are immutable, I am
much less likely to confuse anyone who reads my code later.

This does end up with stupid code like $l_var = $var + ['foo'], but that
can't be helped while preserving clarity.

Now, I would LOVE the ability to manipulate all variables within scope.
That would be very nice and then I would vote for keeping += around.

That would allow for things like:

if empty($foo) {
  $foo = 'bar'
}

Instead of:

if empty($foo) {
  $l_foo = 'bar'
}
else {
  $l_foo = $foo
}

Which is irritating.

Trevor


On Fri, Aug 8, 2014 at 7:55 PM, Andy Parker <a...@puppetlabs.com> wrote:

> I'm looking over PUP-2972, which is closely related to PUP-489, and is
> specified (but changeable, hence this email!) at
> https://github.com/puppetlabs/puppet-specifications/blob/master/language/expressions.md#-operator-8
> and
> https://github.com/puppetlabs/puppet-specifications/blob/master/language/expressions.md#-operator
>
> PUP-2972 has information about what I found by looking at modules from the
> forge and on github to see how += is being used right now. The purpose of
> this is to try to make += consistent with +, the behavior of + to be much
> more predictable, and -= is added by analogy with += existing.
>
> What I'd like to know is:
>
>   * Do the semantics specified make sense?
>   * The recommendation of PUP-2972 suggests just dropping += (and -=)
> because they are confusing. I'm reluctant to do that since it is already in
> use and has been around for a while. Is it useful to keep them around?
>
> The most notable change in functionality is that += won't work for string
> concatenation anymore, because + doesn't do string concatenation. Instead
> you'll need to use string interpolation ($a = "$a$b").
>
> --
> Andrew Parker
> a...@puppetlabs.com
> Freenode: zaphod42
> Twitter: @aparker42
> Software Developer
>
> *Join us at PuppetConf 2014 <http://www.puppetconf.com/>, September
> 22-24 in San Francisco*
> *Register by May 30th to take advantage of the Early Adopter discount
> <http://links.puppetlabs.com/puppetconf-early-adopter> **—**save $349!*
>
> --
> 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/CANhgQXsf-qieFaFOoYo7WkS%2BsdeveLsBGO3pgZpsUV2o5hAjLg%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-dev/CANhgQXsf-qieFaFOoYo7WkS%2BsdeveLsBGO3pgZpsUV2o5hAjLg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvaug...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

-- 
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/CANs%2BFoVT5uS0%2BDL0nC-cj8zxFdc2NMrxOZ574wm%2BEbG7jrB3bA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to