Yeah, I know that it doesn't actually mutate. But it *feels* like it does,
which is the issue.

Trevor


On Sat, Aug 9, 2014 at 4:37 PM, Henrik Lindberg <
[email protected]> wrote:

> On 2014-09-08 21:12, Trevor Vaughan wrote:
>
>> 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.
>>
>>
> Just to be clear, the += does *not* mutate, it creates a new variable that
> shadows the original in an outer scope.
>
>
>  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
>>
>>
> - henrik
> --
>
> Visit my Blog "Puppet on the Edge"
> http://puppet-on-the-edge.blogspot.se/
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-dev/ls60q9%24s0d%241%40ger.gmane.org.
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
[email protected]

-- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoWOPrVQnMWchtB1d6-B1xj6aEBY9Ww%2Bw3F-GH8dQ%2B00JQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to