On 2014-03-08 22:30, Luke Kanies wrote:
On Jul 30, 2014, at 1:02 PM, John Bollinger <john..bollin...@stjude.org
<mailto:john.bollin...@stjude.org>> wrote:
[...]

    Here are the tests for the future parser (as changed by the PR)

          ["thing"              ,"resource", ["thing"]],
          ["[thing]"            ,"resource", ["thing"]],
          ["[[nested, array]]"  ,"resource", ["nested", "array"]],



I still find that last one surprising, but if it really matches the
current behavior then so be it.  What's the rule here, though?  Array
titles are automatically flattened?

Just a small note here:  I implemented this behavior intentionally,
because it seemed the least of the available evils.  When I first added
the ability for resources to have arrays as titles, I didn't have any
available operations for arrays.  So, my choice was:  Fail if you used
nested arrays; change resources to support arrays as titles or behave
appropriately if they got one and couldn't handle it; add complex array
operations (so you could do things like flatten arrays); or just flatten
for you.

In most cases, it's not been a problem, but as we're looking at building
a more coherent and consistent language, it makes sense to revisit this
behavior.

Note that when I implemented this, Puppet had almost no functions
available by default, and no such thing as calling methods on objects,
so implementing "flatten($array)" or "$array.flatten" would have been a
pretty big leap.

I think either would be less of a leap today, and it probably makes more
sense to ask the user to transform their data into a valid form than to
try to do magic transformations.

And, as discovered, we clearly need to become a lot more careful in what
kind of data we accept in these fields overall.

So, to summarize:  Yes, this is intentional, and it made sense at the
time.  It probably doesn't make sense as the default behavior much
longer, though.


While true, it is also a change we do not have to make since it is perfectly ok to continue to flatten the title array (there is no other meaningful interpretation). We will break backwards compatibility if we make it an error.

- 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 puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/lrmcso%24sk7%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to