general sml question

brian <briand-/[email protected]> Mon, 7 Jul 2008 22:30:38 -0700
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
So I'm working on this program (makes pretty graphs) and it needs  
lots and lots of options.

Currently I'm handling this in a vaguely oo-way in which I create  
records with ref fields, and provide "mutators" to change the state.   
Then when I get ready to generate the graph I generate an immutable  
record and proceed.

So you end up with code which looks like:

let
...
in
   setTitle(g, "foo");
   setAxisLimits(0.0, 10.0, 1.0);
   drawGraph(g);
end


This works pretty well, but I'd like to know if there is a more  
functional way to handle this.

My first thought was functional record update (which will be in SMLNJ  
2.0, right ?), but that seems somewhat clumsy:

let val g = newGraph()
     val g = setTitle("foo")
     val g = setAxisLimits(...)
in
   drawGraph(g)
end


The problem being that you have to keep track of the "object", which  
is, I suppose, even more OO.

Variable args don't really work well either.

Any other suggestions ?

Thanks,

Brian



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08