title: Understanding how .Internal C functions are handled in R
body: <p>I wonder if anyone can illustrate to me how R executes a <code>C</code> call from an R command typed at the console prompt. I am particularly confused by <code>R</code>'s treatment of a) function arguments and b) the function call itself.  </p>
  
  <p>Let's take an example, in this case <code>set.seed()</code>. Wondering how it works I type the name in at the prompt, get the source (<a href="https://stackoverflow.com/q/19226816/1478381"><strong>look here for more on that</strong></a>), see there is eventually a <code>.Internal(set.seed(seed, i.knd, normal.kind)</code>, so dutifully look up the relevant function name in the <code>.Internals</code> section of <code>/src/names.c</code>, find it is called <code>do_setseed</code> and is in <code>RNG.c</code> which leads me to...</p>
  
  <pre><code>SEXP attribute_hidden do_setseed (SEXP call, SEXP op, SEXP args, SEXP env)
  {
      SEXP skind, nkind;
      int seed;
  
      checkArity(op, args);
      if(!isNull(CAR(args))) {
      seed = asInteger(CAR(args));
      if (seed == NA_INTEGER)
          error(_("supplied seed is not a valid integer"));
      } else seed = TimeToSeed();
      skind = CADR(args);
      nkind = CADDR(args);
      //...
        //DO RNG here 
      //...
      return R_NilValue;
  }
  </code></pre>
  
  <ul>
  <li>What are <code>CAR</code>, <code>CADR</code>, <code>CADDR</code>? My research leads me to believe they are a <code>Lisp</code> influenced construct concerning lists but beyond that I do not understand what these functions do or <em>why they are needed</em>.</li>
  <li>What does <code>checkArity()</code> do?</li>
  <li><code>SEXP args</code> seems self explanatory, but is this a list of the
  arguments that is passed in the function call?</li>
  <li>What does <code>SEXP op</code> represent? I take this to mean operator (like in binary functions such as <code>+</code>), but then what is the <code>SEXP call</code> for?</li>
  </ul>
  
  <p>Is anyone able to flow through what happens when I type</p>
  
  <pre><code>set.seed(1)
  </code></pre>
  
  <p>at the R console prompt, up to the point at which <code>skind</code> and <code>nkind</code> are defined? I find I am not able to well understand the source code at this level and path from interpreter to C function.</p>