Re: Prize and Milestone as mutable state idioms
"Tyler Close" <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
I've made changes to the discussed JSON writer, based on David's and Monty's feedback. In the process, I renamed the class, so the current version is now at: http://waterken.svn.sourceforge.net/viewvc/waterken/server/trunk/waterken/remote/src/org/waterken/syntax/json/JSONWriter.java?view=markup I also made the interface public and eliminated its remaining dependencies, so that the Java file can be downloaded and used on its own. That wasn't the original goal, but now that so much work has gone into it, might as well make it generally reusable by others. On Wed, Jul 2, 2008 at 12:13 PM, David Wagner <[email protected]> wrote: > Basically, I think there is some invariant among the entire tree of > {Value,Object,Array}Writers that are associated with each other: at > most one of them can be "active", and calling a method on an inactive > one must throw an exception and not modify the state of the tree. > Moreover there are certain points in the code that hand off who is > "active", and this must only happen at the appropriate points. > (Is that right?) This invariant is tricky to verify. I haven't yet come up with a way of better expressing this invariant in code, so I gave up and just wrote a comment explaining how the invariant is currently enforced. I'm still interested in finding a way to say this in code, that doesn't require reifying the JSON tree structure first. I'm not sure if the current pattern is a general purpose one, but its worth some more thought. --Tyler