One of the lectures that I attended last year was Programming Methodology and Philosophy of Programming Languages. The lecture was mostly about history of programming languages and how several features evolved, disappeared and than after many years appeared again in another programming language.
As I final work I decided to write an article that describes ideas that influenced the design of the C# 3.0 language. Some of these features are known from functional languages (for example from LISP or Haskell), some other were developed at Microsoft Research and appeared in the F# language or Cω. I also wanted to show in what ways are these features limited in the C# 3.0. I think that thanks to these limitation, the C# 3.0 is still a simple (or at least not difficult) to understand which is very important for mainstream language, but I find it interesting to know what is possible in other (less limited) languages.
F# quotations allows you to easily write programs that manipulate with data representation of program source code. If you're not familiar with quotations I recommend reading my previous article  that contains short introduction to this topic first. Quotations can be used for example for translating subset of the F# language to another code representation or another language.
To get the quotation data of the expression you can either use
<@@ .. @@>
resolveTopDef function. In the first case the code written
between the "
<@@" and "
@@>" is converted to data during the compilation.
resolveTopDef function allows you to get quotation data of top-level
definition (function) from compiled library at runtime (you have to use
command line switch while compiling the library). I mentioned that quotations can be used to represent
only subset of the F# language. Currently, one of the quotation limitations is that it's not possible to
enclose the whole class in the quotation operators. It is also not possible to get the representation
of the whole class at runtime nor the representation of class members (for example methods).
In this article I'll present a simple method that makes it possible to use F# quotations for working with classes as well, however this is rather a prototype that can be used for experimenting and discovering areas where working with classes might be useful, not a fully working solution.
Some time ago, I wrote an article about useful utility called F# quotations visualizer.
This utility can be used to show visual representation of F# quotations, that can represent (subset of) source code written in F#.
There are two ways that you can use to get F# quotations - first is using operators
<@@@@ ... @@@@> (this
returns quotation of the code written inside the operator), second method is to get quotation of top level definition from compiled
F# assembly (you have to explicitly enable this using command line switch
--enable-quotation-data while compiling assembly).
Because I added several new features to the original Quotations visualizer, I decided to publish the latest version - here is the list of main improvements:
- Rewritten using active patterns (new F# language feature)
- It is possible to extract quotations from compiled F# assembly (if it contains quotation data)
- Added support for several missing language constructs