Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I really think you will benefit from establishing the following function calling coding guidelines:</p> <ol> <li><p>As in all other places, always be <code>const</code>-correct.</p> <ul> <li>Note: This means, among other things, that only out-values (see item 3) and values passed by value (see item 4) can lack the <code>const</code> specifier.</li> </ul></li> <li><p>Only pass a value by pointer if the value 0/NULL is a valid input in the current context.</p> <ul> <li><p>Rationale 1: As <strong>a caller</strong>, you see that whatever you pass in <em>must be</em> in a usable state.</p></li> <li><p>Rationale 2: As <strong>called</strong>, you know that whatever comes in <em>is</em> in a usable state. Hence, no NULL-check or error handling needs to be done for that value.</p></li> <li><p>Rationale 3: Rationales 1 and 2 will be <em>compiler enforced</em>. Always catch errors at compile time if you can.</p></li> </ul></li> <li><p>If a function argument is an out-value, then pass it by reference.</p> <ul> <li>Rationale: We don't want to break item 2...</li> </ul></li> <li><p>Choose "pass by value" over "pass by const reference" only if the value is a POD (<a href="https://stackoverflow.com/questions/146452/what-are-pod-types-in-c">Plain old Datastructure</a>) or small enough (memory-wise) or in other ways cheap enough (time-wise) to copy.</p> <ul> <li>Rationale: Avoid unnecessary copies.</li> <li>Note: <em>small enough</em> and <em>cheap enough</em> are not absolute measurables.</li> </ul></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload