Re: Prize and Milestone as mutable state idioms

"Monty Zukowski" <monty-aaXZSQuah4Ac3H1WRXY/HAC/[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.