title: Representing arrays and records in bytecode
body: <p>I'm creating a programming language from scratch in C, and I'd prefer not to use third-party code for variable handling.</p>
  
  <p>Firstly, what's the best way to represent array assignments, like <code>apples_in_crate[5] = 170</code>, in bytecode form?</p>
  
  <p>Obviously, <code>apples = 170</code> could be represented as:</p>
  
  <pre><code>PUSHSCALAR ("apples")
  PUSHREAL (170)
  ASSIGNSCALAR
  </code></pre>
  
  <p>but things get a lot more complicated when it comes to arrays. Any suggestions?</p>
  
  <p>Secondly, how would you represent <code>crate[5].apples = 170</code> (a record) in bytecode?</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Clarification: I'm writing an interpreter, so the size of an array is <em>not</em> known at "compile-time" or parse-time. For example, the following (abstract) code would be quite valid:</p>
  
  <pre><code>// Note: NUMBER_OF_CRATES is not known at compile-/parse-time,
  // it could even be a dynamic expression.
  array apples_in_crate[NUMBER_OF_CRATES]
  
  for crate = 1 to NUMBER_OF_CRATES
     apples_in_crate[crate] = randint (101) + 100
  end for
  </code></pre>