1

I know it is related to this SO question and this one, but I want to know, if (and how) it is possible to create new F# functions at runtime.

By this I mean something like using the REPL without showing it. Is there any other option than CodeDOM and Reflection or Quotations?

If it is not possible in F#, is it possible in any other .Net Language?

Community
  • 1
  • 1
Dominik G
  • 1,459
  • 3
  • 17
  • 37

1 Answers1

2

Sure you can, that's what the DLR (Dynamic Language Runtime) is for. It's used by IronPython, IronRuby, and other dynamic languages which work exactly as you describe. The DLR is just a library, so you can use it from within F# if you want.

Another option is to implement similar functionality using F#'s higher-order functions -- this would be very flexible, but ultimately somewhat slower because the .NET CLR won't be able to do much (if anything) in the way of optimization.

Jack P.
  • 11,487
  • 1
  • 29
  • 34
  • Thanks. I only wanted to use F# for this, but since it is possible in C# I'll use it, because most of my application is in C#. – Dominik G Aug 21 '12 at 12:07