Xref: utzoo comp.object:2359 comp.lang.functional:553 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!tut.cis.ohio-state.edu!snorkelwacker.mit.edu!ai-lab!life!burley From: burley@pogo.ai.mit.edu (Craig Burley) Newsgroups: comp.object,comp.lang.functional Subject: Re: Global program state. Message-ID: Date: 3 Jan 91 12:43:44 GMT References: <27823155.211e@petunia.CalPoly.EDU> <27109:Jan301:33:4391@kramden.acf.nyu.edu> Sender: news@ai.mit.edu Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139 (617) 253-8568 Lines: 39 In-reply-to: brnstnd@kramden.acf.nyu.edu's message of 3 Jan 91 01:33:43 GMT In article <27109:Jan301:33:4391@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: In article <27823155.211e@petunia.CalPoly.EDU> jdudeck@polyslo.CalPoly.EDU (John R. Dudeck) writes: > In the book, _Principles of Functional Programming_, by Glaser, Hankin, > & Till, it is stated, "the notion of global state that may change > arbitrarily at each step of the computation has proved to be both > intuitively and mathematically intractable." That's a nice religion but it's simply not true. I am working on a formal, quite mathematical, definition for the semantics of my Q language. Q supports nonpreemptive threads and some amount of parallel processing. It supports data hiding even better than Ada---Piercarlo, if you're reading this, I stole your ideas about visibility in the opposite direction. Yet the notion of global state proves quite useful in the definition. Yes, I have a much easier time thinking about any global state if I imagine that all procedures have an "implicit" argument passed among them that contains the global state (an array of bytes representing all of memory, if necessary, perhaps even including I/O). In the object-oriented model, a similar approach can be taken -- think of global state as one huge object (if necessary -- multiple smaller objects when it is easily shown they don't interact) that all other objects know about, and treat all reads and writes to that state as messages to that object. Then any intuitions or mathematics (proofs) become easier, I think. The higher up one can abstract the global state (the more distinct one can show all of its elements to be, and the "closer" each element can be to getting "absorbed" by a few functions or objects), the easier the state was to deal with in the first place. Note this does not mean it is wise to start a new project using lots of global state -- I'm just pointing out that one can understand existing systems using this approach. Dan, does your Q language (or your formal definition) use this technique, or something similar, to deal with the global state you use in its definition? -- James Craig Burley, Software Craftsperson burley@ai.mit.edu