News for hackers. Stuff that matters.
Re:Defunctionalisation: An underappreciated tool for writing... by barrkel on Monday March 09, 2020 @04:29PM (#22529396)
C#'s Expression<T> is almost exactly what you use in your example, baked into the language - you specify a lambda but the compiler emits construction of an expression tree.

https://docs.microsoft.com/en-us/dotnet/api/system.linq.expr...

https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

Re:Defunctionalisation: An underappreciated tool for writing... by Smaug123 on Wednesday March 11, 2020 @03:00AM (#22543724)
Indeed, we have used `Expr` and the `ReflectedDefinition` attribute internally in F#. However, if the user is capable of giving you literally anything, you'll struggle to optimise it! We've found it important to artificially restrict what the user can give us, by explicitly modelling the domain.