Model reflection, CS 106

Draft

The Tuesday reflection is intended to get you to think about your code and what you’ve learned without requiring a whole lot of work. I can’t provide model answers to the module 1 reflection questions, but I’ve faked up some answers so I can show you roughly the scope of what I’m looking for—mostly short answers.

Model project points

I’ve made up these fake project points:

  1. Completeness. The makefile builds svm-test, which passes its three tests.

  2. Projection. Since projection can fail, I’ve made sure that every projection function fails in a consistent way.

  3. Embedding. Embedding always succeeds, and I can point to two different examples of embedding function, with two different result types, that always succeed—and my other embedding functions do as well.

  4. Memory management. I understand memory management at a level where a simple test can run without memory errors and can return all the C memory that it allocates.

  5. Single point of truth (code edition). My model code demonstrates the concept of a single point of truth.

  6. Single point of truth (web edition). My course web pages demonstrate the concept of a single point of truth.

  7. Specification. I can point to an interface module where preconditions for calling functions are clearly specified, and an implementation where those preconditions are enforced.

  8. Reuse of code. I can say how you would reuse a C module to implement another language not in the Scheme family.

And here are my claims:

  1. Binary builds; tests pass.

  2. Every value-projection function in value.h fails in the same way: by calling function typeerror. The only other projection that can fail is opcode, which can project to an invalid opcode. This failure is detected in a different way (line 58 of vmrun.c), but it calls runerror. Since typeerror and runerror are defined in the same module (vmerror.c) and do the same thing (print an error message and halt the program with abort), I claim they fail in the same way.

  3. Function mkNumberValue always succeeds. Function eR3 succeeds only if its precondition is met (arguments are actually 8-bit register numbers). So maybe I haven’t earned this point?

  4. valgrind reports no errors and no leaks.

  5. My vmstate.h defines the size of the literal pool in macro LITSIZE. All other references use the macro (or sizeof).

  6. Every web page has a navigation bar at the top. The navigation bar is defined by function navbar on line 208 of file /comp/106/lib/pandoc-web. To compute the correct URL for each navigation target, the function uses the relative URL of the page being generated, which is defined in one place on line 22 of file /comp106/www/base.mk, where options -M target=$target are passed to pandoc. I’m unreasonably proud of this.

  7. The EBNF protocol in check-expect.h captures the states in which functions check and expect may be called. If the specification is violated, an assertion fails on line 31 or 39 of file check-expect.c.

  8. I adapted the vmstring.c code from the Lua VM. So it could be used to implement Lua, or indeed any language where it makes sense for the implementation to intern short strings—for example, Erlang, which uses atoms as first-class values.

Draft