[e-lang] Prize and Milestone as mutable state idioms

Monty Zukowski monty at codetransform.com
Tue Jul 1 13:26:14 CDT 2008


I really like those idioms of Milestone and Prize, however in the code
for ValueWriter, I'm not clear on why Prize is important to
understanding the code.  I also don't understand:

  116         protected ValueWriter
  117         startMember(final String name) throws IOException {
  118             if (!member.isWritten()) { throw new NullPointerException(); }
  119
  120             member = new ValueWriter(inset, out); // prevent
calls until after
  121

In general I'm having trouble understanding the expected flow through
the code, and after 15 minutes of studying it I'm giving up.

I was going to comment that the below code will throw a
NullPointerException if called twice, but then I noticed
NullPointerExceptions being thrown on purpose elsewhere for
essentially the same reason.  Oh, maybe that's why you use Prize, to
force that NPE instead of possibly writing the output twice?

   81     protected ObjectWriter
   82     startObject() throws IOException {
   83         final Writer out = output.claim();
   84         out.write('{');

Monty


More information about the e-lang mailing list