[OE-core] subtle weirdness when you combine "_append" with "+="?

Robert P. J. Day rpjday at crashcourse.ca
Wed Aug 17 14:23:59 UTC 2016


On Wed, 17 Aug 2016, Ulf Magnusson wrote:

> On Wed, Aug 17, 2016 at 3:21 PM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
> > On Tue, 16 Aug 2016, Khem Raj wrote:
> >
> >   ... big snip ...
> >
> >> the _append/_prepend in conjunction with += is a undocumented
> >> behavior however, I do not see it as much a side effect. But in
> >> future bitbake may silently change its behavior, so I agree its
> >> always good to stay in safe waters.
> >
> >   so just to finalize this discussion, my thoughts on a reasonable and
> > meaningful standard for append/prepend/etc/etc would be to *always*
> > use the "mathematical" operators +=/.=/=+/=. except in two situations:
> >
> >   1) when parsing *must* be delayed until the end, or
>
> I agree as long as that *must* also includes the kind of situation
> described for foo.bbclass in
> https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages.
> I think you ought to follow the principle of least surprise.

  agreed. i guess a simpler way to state it is that one should never
use "_append" unless it's necessary. that pretty much covers all
situations.

> >   2) when combining the operation with an override (for which i'm
> >      quite sure there is no equivalent when using +=, etc, right?)
> >
> > i'm a big fan of simplicity, in the sense that, if an append operation
> > does not *require* "_append", it shouldn't use it. because if i see an
> > expression:
> >
> >   VAR_append = "..."
> >
> > then i immediately wonder if there is a *reason* for using "_append"
> > rather than "+=" or ".=", or if that is just the developer's personal
> > preference. and i really, really, really hate having to guess.
> >
> >   oh, and of course, never, ever combine "_append" with "+=" or ".=".
> > does that sound like a reasonable coding style?
>
> Sounds reasonable to me. Using _append rather than += can also be
> a bug in certain situations. For example, the following does not
> guarantee that " value1 value2" appears right after "--flag":
>
> FLAGS = "--flag"
> FLAGS_append = " value1"
> FLAGS_append = " value2"
>
> Any earlier FLAGS_append value would appear before those two.

  i don't see that as a "bug"; it's exactly the way it *should*
operate. the above is more an example of someone not *understanding*
how those operators work.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================




More information about the Openembedded-core mailing list