[Haskell-cafe] Re: FRP for game programming / artifical life simulation

Peter Verswyvelen bugfact at gmail.com
Wed Apr 28 17:21:08 EDT 2010

As a side note, it's interesting that C# doesn't allow serialization
of closures (anonymous delegates). The compiler-generated name
assigned to an anonymous delegate can be different after each
re-compilation. This is also really annoying in C#/.NET, since one
must explicitly add a named method if serialization is needed. So I
wander how Clean solves this. I mean, consider

data MyData = MD (Int->Int)

myFunc x = x+1
myState1 = MyData myFunc
myState2 = MyData (\x -> x+1)

I can imagine that serializing myState1 is not too difficult, since it
should be possible to lookup the name of the compiled function

However, what about serializing myState2? The lambda function has no
name, and it is not obvious to me how to give it a name that is unique
enough to survive a couple of iterations of source code modifications.

On Wed, Apr 28, 2010 at 9:56 PM, Gregory Crosswhite
<gcross at phys.washington.edu> wrote:
> On Apr 28, 2010, at 3:41 PM, Limestraël wrote:
>> I think the problem with function serialization is that unlike languages which run over a virtual machine, bytecode generated by GHC is platform-specific (just as compilated C or C++) and therefore can run directly on top of the system, which is far faster but less portable.
> Is this true?  I thought that ghc has separate machine code and byte-code modes, and inferred that the latter was platform-independent.  Is the latter platform-specific because it is just a different way of organizing different ways of (unlinked) machine code, or because parts of the byte-code depend on things like the size of integers in the compilation machine that are platform-dependent?
> Also, it is worth noting that Clean supports serialization of values including closures.  It's not entirely clear to me how they do this, but looks like some combination of seeing whether a referenced routine is already in the current executable, then seeing whether it is in a nearby library, and then finally just-in-type compiling the serialized platform-independent bytecode into native code.
> Cheers,
> Greg
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list