When you say "supplied at runtime" -- how will it be supplied?

This probably won't help, but F# closures and function results can be serialized using binary serialization. But of course that requires the original DLL containing the IL.

By on 11/30/2009 2:18 PM ()

Through a file stored on the server which will be loaded when the server starts; so not at compile time.

If F# closures can be serialized then that's good news, from what I read on delegates the problem was that the actual object itself was just a pointer and if it was serialized it could not be deserialized again in a useful way, but if that's not true then this whole problem has become much more straightforward.

In that case, I can, at runtime, accept a function that generates the trained classifier (another function) when given a training set and then store that trained classifier to a binary file, loading it again when the server is restarted?

By on 11/30/2009 2:57 PM ()

If the functions are being provided via a DLL, then binary serialization should work fine, assuming you have all the DLLs involved. F# closures are compiled to regular objects (they aren't delegates, but even a delegate representing a closure will need a backing object; you might be able to reflect on the delegate and figure out the methodinfo and instance object...).

For example:

let f x = (fun y -> x + y)

Then applying f to some value will generate an object containing x, and the code for the function. That part will serialize (or did in earlier versions of F#; I have not tried it recently). But note this is not version safe; any changes to the compiled DLL can render the serialized object useless -- it's rather brittle.

By on 11/30/2009 3:28 PM ()

So provided that the context in which the functions are being loaded at runtime is the same as which they were originally being serialized in, it should work normally with binary serialization without any extra effort being needed? That will help.

How do you unbox the function after you load it? F# seems to want to restrict anything that gets unboxed to values.

By on 11/30/2009 3:59 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper