title: Pass-by-name and Pass-by-value-result
body: <p>For my programming languages class, I am trying to understand how pass-by-name and pass-by-value-result work.  I realize these aren't used hardly at all in mainstream languages, but I am wanting to get a feel for how they work.  As an example (language agnostic):</p>
  
  <pre><code>void swap(int a, int b){
      int t;
      t = a;
      a = b;
      b = t;
  }
  void main() {
      int val = 1, list[5] = {1, 2, 3, 4, 5}
      swap(val, list[val]); 
  }
  </code></pre>
  
  <p>What would the values of val and list be after swap is called for both pass-by-value-result and pass-by-name.</p>
  
  <p>An explanation would be great too.</p>
  
  <p>From what I deduced, it got value-result: val=2, list={1,1,3,4,5} and name: val=3, list={1,2,1,4,5}.  I'm very unsure about those results.</p>
  
  <p>Also does it change the way both of these methods work when an array is passed as opposed to a single int?  Thanks for any help in advance.</p>