On Feb 25, 7:45 am, Jules <jules.gosn...@gmail.com> wrote:
> I want to include functions in my metadata - e.g. I might want to
> specify a version comparator function to allow tables to decide
> whether a new version that they are presented with is actually more
> recent than the one that they already hold. I might want to support
> multiple primary or version keys by providing a pk-fn or version-fn
> etc.
>
> When I serialise the metadata from server to client, the client cannot
> deserialise the metadata because the classes that were created
> server-side to implement the functions are not present.

We cooked up a simple library that allows for serializing functions at
the Seattle Clojure group:

  https://github.com/Seajure/serializable-fn

It's able to serialize lexical scope along with the function, but
there may be certain types of expressions that would cause trouble
when they are closed over. It should be pretty easy to fix if you're
interested in improving it a bit.

This approach is a bit naive as it requires you to know in advance
which functions you want to serialize and use the serializable fn
macro, but depending on your needs it could get the job done. It has
the advantage of being many many orders of magnitude simpler (20 LOC)
than any other function serialization mechanism.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to