[fluxus] 0.12b1 + cvs merge
Claude Heiland-Allen
claudiusmaximus at goto10.org
Fri Jan 12 09:22:04 PST 2007
Dave Griffiths wrote:
>> thinking about it some more, the front end app is scheme independant now
>> too, it would be doable to use it as an editor to a haskell
>> interpreter/repl with some equivelent to every-frame.
Excellent!
> and - thinking of haskell particually, there are a few things about the
> philosophy going on with fluxus. basically what it boils down to is that
> computer graphics works very very well imperatively.
Haskell can sequence actions too, most commonly with the IO monad.
> things like (push) (pop)
HOpenGL has something like:
withPushPop action = do { push ; action ; pop }
but I've forgotten its real name.
> and (grab) use stacks for hierachically storing
> state, which would be (I imagine) considered very bad taste to the
> hardcore functional programmer.
I have impeccably bad taste ;)
> scheme is quite well matched to this as
> it's a hybrid approach - and I like it for that. it's something I've been
> meaning to mention at some point, because it sort of happened by accident.
I understand.
> I guess you could implement (draw-cube) etc - but would you have to
> specify the entire state with it every time?
Yes and no. You could have something like:
drawSphereBase :: FluxusStateHandle -> Float -> Float -> IO ()
drawSphereBase handle count1 count2 = do
state <- readIORef handle
... call out to libfluxus ... [*]
return ()
and define draw-sphere with the state handle inside it:
fluxus = do
state <- ... call out to C to get a pointer to Fluxus' state ...
handle <- newIORef state
drawSphere 10 10
where
drawSphere :: Float -> Float -> IO ()
drawSphere = drawSphereBase handle
But that's only necessary if the call in [*] needs to be passed a
pointer to Fluxus' state. Otherwise, if the state is stored entirely in
libfluxus, you could just:
drawSphere :: Float -> Float -> IO ()
drawSphere = do { ..call libfluxus.. ; return () }
and
buildSphere :: Float -> Float -> IO (Ptr sometype)
sphere <- buildSphere 10 10
It's essentially the same issue as trying to do OOP in C rather than
C++, you have to pass *this explicitly rather than it being passed for you.
> I think the answer would
> involve the word monad somewhere :)
:)
Claude
More information about the Fluxus
mailing list