<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>9985</bug_id>
          
          <creation_ts>2016-07-20 11:14:51 +0000</creation_ts>
          <short_desc>Suggested clarification and motivation for the override-style operators</short_desc>
          <delta_ts>2016-08-01 22:31:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>BitBake User Manual</product>
          <component>bitbake-manual</component>
          <version>2.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>01 August 2016: IN PROGRESS REVIEW</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.2 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ulfalizer</reporter>
          <assigned_to name="Scott Rifenbark">srifenbark</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>sgw</cc>
    
    <cc>srifenbark</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Done (doc changes complete)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>64214</commentid>
    <comment_count>0</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-07-20 11:14:51 +0000</bug_when>
    <thetext>Hello,

I suspect the override-style operators (_append, _prepend, _remove) would be
much easier to understand if some motivation was given. The existing
descriptions are also vague in places.

I suggest the following changes:


Add to the end of &apos;3.1.9. Removal (Override Style Syntax)&apos;:

  Like _append and _prepend, _remove is deferred until after parsing completes.


Add a new section &apos;3.1.10 Motivation behind the override-style operations&apos;:

  An advantage of the override-style operations _append, _prepend, and _remove
  (compared to e.g. += and =+) is that they provide &quot;guaranteed&quot; operations.
  For example, consider a class foo.bbclass that needs to add the value &quot;val&quot;
  to the variable FOO, and a recipe that uses foo.bbclass as follows:
  
    inherit foo
  
    FOO = &quot;initial&quot;
  
  If foo.bbclass uses the &apos;+=&apos; operator, as follows, then the final value of
  FOO will be &quot;initial&quot;, which is not what we want:
  
    FOO += &quot;val&quot;
  
  If on the other hand foo.bbclass uses the _append operator, as follows, then
  the final value of FOO will be &quot;initial val&quot;, as intended:
  
    FOO_append = &quot; val&quot;
  
  Note {
  It is never necessary to use += together with _append. The following sequence
  of assignments will append &quot;barbaz&quot; to FOO:
  
    FOO_append = &quot;bar&quot;
    FOO_append = &quot;baz&quot;
  
  The only effect of changing the second assignment to
  
    FOO_append += &quot;baz&quot;
  
  is to add a space before &quot;baz&quot; in the appended value (due to how the +=
  operator works).
  }
  
  Another advantage of the override-style operations is that they can be
  combined with other overrides, as described in
  [3.2. Conditional Syntax (Overrides)].


In &apos;3.2.3. Examples&apos;, change

  OVERRIDES = &quot;foo&quot;
  A = &quot;Y&quot;
  A_foo_append = &quot;Z&quot;
  A_foo_append += &quot;X&quot;

to

  OVERRIDES = &quot;foo&quot;
  A = &quot;Y&quot;
  A_foo_append = &quot;Z&quot;
  A_foo_append = &quot;X&quot;

and change

  ...leaving the variable set to &quot;Z X&quot;

to
  
  ...leaving the variable set to &quot;ZX&quot;

This avoids tricking people into thinking += is necessary when using _append. I
tested it out to make sure it was correct.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64282</commentid>
    <comment_count>1</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-07-21 17:57:29 +0000</bug_when>
    <thetext>Ulf, 

Here is the change for 3.1.9 - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#removing-override-style-syntax

Here is the new 3.1.10 section - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages

Here is the 3.2.3 change - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-interaction-worked-examples.  

thanks, 
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64287</commentid>
    <comment_count>2</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-07-21 18:10:54 +0000</bug_when>
    <thetext>A few nits, otherwise fine:

 - &quot;...changing the second assignment in the previous example...&quot; would be clearer as &quot;...changing the second assignment in the previous example to use &apos;:=&apos;...&quot;

 - There&apos;s an ending parenthesis missing in &quot;(due to how the &apos;+=&apos; operator works.&quot;

 - The following also needs to say &quot;ZX&quot; rather than &quot;Z X&quot;. I missed that when I first went through it:

  Finally, applying the override for &quot;foo&quot; results in the conditional
  variable A becoming &quot;Z X&quot; (i.e. A is replaced with A_foo).

Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64291</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-07-21 18:26:27 +0000</bug_when>
    <thetext>Here are the changes: 

 * http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages

 * http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-interaction-worked-examples

I wondered about the second one.  I almost went ahead and changed it but figured if it was wrong you would catch it. 

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64292</commentid>
    <comment_count>4</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-07-21 18:29:30 +0000</bug_when>
    <thetext>You put too much trust in me. ;)

Looks good to me now.

Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64293</commentid>
    <comment_count>5</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-07-21 18:31:01 +0000</bug_when>
    <thetext>Thanks - closing out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64703</commentid>
    <comment_count>6</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-07-30 20:11:21 +0000</bug_when>
    <thetext>Ops... I made a typo:

  ...example to use &quot;:=&quot; would be to add...

should be

  ...example to use &quot;+=&quot; would be to add...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64741</commentid>
    <comment_count>7</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-01 18:56:39 +0000</bug_when>
    <thetext>Ulf, 

See the note in http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages for the fix.  I should have realized that had to change as well. 

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64757</commentid>
    <comment_count>8</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-01 22:02:11 +0000</bug_when>
    <thetext>Hello,

As mentioned in bug 9984, the changes for this bug disappeared. Other changes besides 9984 and 9985 might be affected too.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64759</commentid>
    <comment_count>9</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-01 22:25:07 +0000</bug_when>
    <thetext>Check the link again for the change... Same explanation as the Bug 9984.

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64761</commentid>
    <comment_count>10</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-01 22:28:51 +0000</bug_when>
    <thetext>Looks good now!

Thanks,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64762</commentid>
    <comment_count>11</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-01 22:31:27 +0000</bug_when>
    <thetext>Cool - setting doc flag to &quot;done&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>