5

I thought that I would be able to use quotations to accomplish what I'm trying to do (create a tree of expressions which I can store in a DB and execute later on). Much to my dismay, however, I've learned that quotations are not serializable and cannot be compiled (I would like to avoid F# PowerPack because the performance is bad).

So I'm curious to know, are F# quotations useful for anything at all? Of what use is a data structure representing code if it can't be compiled back into code? What am I missing here?

Related: Another limitation of F# quotations? What are F# quotations?

Community
  • 1
  • 1
Jacobs Data Solutions
  • 4,850
  • 4
  • 33
  • 38
  • 3
    In F# 3.0 you no longer have to reference PowerPack to compile quotations. See [`LeafExpressionConverter.EvaluateQuotation`](http://msdn.microsoft.com/en-us/library/hh324037.aspx) on MSDN. – Daniel Apr 17 '13 at 14:14
  • 2
    The Core lib also contains a function for converting `Expr<'T>` to `Expression`. I bet you can find a good serialization library for LINQ expressions, if you're okay with storing them instead. – Daniel Apr 17 '13 at 14:24
  • Thanks for the link to the MSDN article. I was hoping to avoid the overhead of the conversion to a LINQ expression but I guess I'll have to bite the bullet on this one. – Jacobs Data Solutions Apr 17 '13 at 14:40

1 Answers1

5

Yes they are useful for something.

Wikipedia says

F# quotations are used for various purposes including to compile F# code to JavaScript and GPU code.

I've experimented with them and created a F#-Code to ActionScript compiler.