[Haskell-cafe] How to variables

Claus Reinke claus.reinke at talk21.com
Mon Jul 18 20:20:12 EDT 2005

> >> I'm doing a 3D simulation. Now I need something like variables in
> >> imperative languages. My mainLoop check for new events and renders
> >> scene.

> I saw it. The problem is, I need an amount of 100*X of mutable variables
> to implement the system (camera position, rotation, aceleration, ...,
> position and deformetion infomations for every object, ..., renderer
> situations [like temprary fading and other efects], ... and more)

| Then you probably want a big labeled record,

depending on your needs, you might even want to go a step further,
and design a scene description format for your 3d simulation. instead
of updating and interpreting global variables, or passing a large record
around, you would pass around a higher-level description of the state
of your simulated environment. 

your mainLoop would compute both the current scene to be rendered 
and the follow-on state to be passed to the next round. much easier to 
read, as all the low-level updates are confined to the mainLoop, and 
both the scene description and its interpretation/rendering are 
composed from smaller parts. the scene description language would
be the interface between implementing your 3d simulator and 
describing what is to be simulated.

perhaps the following might give you an idea of the possibilities:

http://www.conal.net/papers/  (Fran, Vertigo, Pan)
http://users.info.unicaen.fr/~karczma/arpap/  (Clastic)


More information about the Haskell-Cafe mailing list