On Sep 15, 2008, at 3:29 AM, Brice Figureau wrote:

> Brice Figureau wrote:
>> Hi,
>>
>> Here is an attempt to provide an append variable operator (see below
>> for an example). My minimal testing show that it seems to work fine
>> in simple manifests.
>>
>> My aim is to gather comments/reactions from the community regarding
>> this feature which was previously asked (and that I wanted myself).
>> Let me know if that's something that _shouldn't_ be done: I know
>> puppet vars are write-only by design, so changing their values might
>> open a pandora box I'm not aware of.
>
> I meant write-once of course, and not write-only.
> Note that it is possible to allow the append operator only in a new
> scope and raise and error otherwise.
> Ie allow sth like:
>
> $var = 'puppet'
> class klass {
>  $var += ' is great'
> }
>
> but not:
> $var = 'puppet'
> $var += ' is great'
>
> It is just a matter of checking that the scope doesn't yet contain the
> variable.


I'm not opposed to this, and can see why people are interested in this.

Just to be clear, this works by basically making a new variable in the  
current scope that is a concatenation of the specified variable and  
the new text/array, right?

If so, then that seems perfectly reasonable to me, since it's very  
similar to just using something like:

$othervar = "$var new text"

It only affects lower scopes, rather than modifying the original  
value, so it should work great.

As to tests, there should be sufficient lexer tests, but I agree that  
we don't have parser tests to speak of; all I've got are integration  
tests in the form of snippets, like you already have done.  It might  
be a good time to create that parser unit test file and add tests for  
this code. :)

I think the major changes, though, are in the scope class, and it's  
also only tested in test/ rather than spec/.

-- 
Life is too short for traffic. --Dan Bellack
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


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