Serializing Functions / Methods / Closures

Hi all,

over the last months I’ve spent quite some time to bring JLD2 back up to speed. One of the remaining pain points is that it is not possible to properly store and recover (anonymous) functions
and closures. This has been requested way too many times.

I’m aware that this is a difficult topic and that there probably will
be edge cases that can’t work for one reason or another. (And likely for good reasons).

Still, I’m mostly concerned with the simpler things e.g. storing simple closures and anonymous functions that commonly appear as fields in larger structures. The struct part of closures already gets serialized properly and only the attached method is missing.

I’ve experimented with this for myself and adapted some code from
BSON (BSON.jl/anonymous.jl at master · JuliaIO/BSON.jl · GitHub)
and got very basic things working but, honestly, I don’t understand what I’m doing.

So, here are my questions:
Is there more information beyond the julialang dev-docs that I can read?
(e.g. what do the fields mean? What is the purpose of the structure?
When are which fields of Method, TypeName, etc. initialized ?)
Would anyone be willing to help me work on this ?

Best,
Jonas

12 Likes