You can serialize and deserialize quotations with normal serialization methods, such as BinaryFormatter:

1
2
3
4
5
6
7
8
9
 

        let bf = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
        let ms = new System.IO.MemoryStream()
        bf.Serialize(ms, <@ fun x -> x + 1 @>)
        ms.Seek(0L, System.IO.SeekOrigin.Begin) |> ignore
        let x = bf.Deserialize(ms) :?> Quotations.Expr<int -> int>
        x

There are some issues with using this for remote execution. First, there's currently no quotation -> IL compiler, AFAIK. There's a Quotation -> Linq Expression converter (that has some limitations on what it can do), and then you could use the Expression compiler. Second, quotations can't include type definitions, so you're going to have to transmit the typedefs over to the remote side somehow.

These issues are solvable (write the compiler, reflect and serialize typedefs too), but, why bother with quotations? If your cloud service is going to execute arbitrary code, then why not just send it a .NET assembly and have it execute that?

By on 12/29/2009 2:20 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