On Thursday, February 25, 2016 at 8:55:01 AM UTC-6, Trevor Vaughan wrote: > > Hmm..... > > I think, as long as it is documented, then whatever behavior is > deterministic is fine. > ' > I think that there is value in the following resolutions: > > Notify['left'] -> [] -> Notify['right'] > * Noop since there is nothing in [] > > Notify['left'] -> [] -> Notify['right'] > Notify['left'] -> Notify['right'] > * First == Noop > * Second == Expected ordering > >
I flip-flopped a bit on this. I started from the position that it would be inappropriate for Notify['left'] -> $stuff -> Notify['right'] or Notify['left'] -> Stuff<||> -> Notify['right'] ever to fail to cause Notify['left'] to be applied before Notify['right'], as indeed it now does fail to do in the event that the stuff in the middle represents zero resources. My basis there was that it is counterintuitive for such expressions to not establish relative ordering of the two Notifys. Ultimately, however, that basis is completely subjective. Others might reasonably intuit that such an expression would have exactly the semantics it actually does have, which are roughly equivalent to those of Notify['left'] -> $stuff $stuff -> Notify['right'] . Upon reflection, this alternative is less magic. It falls out naturally from understanding that chain operators associate from left to right, and that each binary chain expression *evaluates to* the value of its right-hand operand. That some people might find that behavior surprising is a consideration, but not a primary one for me. Moreover, this isn't really all that novel a problem. Consider, for instance, this Ruby code: a = 0 b = 1 c = 2 print "oops" if a < b < c # NoMethodError Note also that this C analog actually prints the result you might naively expect: #include <stdio.h> int main() { int a = 0, b = 1, c = 2; if (a < b < c) puts("ok"); return 0; } . Its output is the same if you swap a and b, though, yet it differs if you instead swap a and c. (Hint for non-C-ers: the Ruby result gives a good clue to what happens in the C example.) There might be more grounds for argument if the chain operators were just now being designed from scratch, but I see no justification for changing their reasonable and established behavior, especially since it is conceivable that the current behavior is in fact being intentionally leveraged at some sites. I favor the resolutions Trevor presented. > Notify['left'] -> Undef -> <Whatever> > * Error since Undef is in the relationship > The Undef case is to some extent a separate question. I'm inclined to agree again that it should be an error for an operand of a chain operator to be undefined, but if that's not how it works now then I am ambivalent about whether the behavior should be changed. John -- 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/57a6a258-b4b9-45a5-bf2c-cca8ef5cea74%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.