How to work with WebSharper translator?

Can someone explain how to work with WebSharper translator in combination with F #? Does the F # code translate to JS itself or does the F # compiler use it?

In the second case, what does the F # compiler do when it finds the [] attribute in the source? Does the compiler develop functions in any case and during the execution of the JS construct as a reflection from the compiled bytecode or something else?

+4
source share
1 answer

I am developing WebSharper. Good question!

Example: compilation looks something like this:

a.dll: a.fs b.fs c.fs fsc ... a.dll.js: a.dll WebSharper.exe .. 

When functions are annotated using [<JavaScript>] , which is an alias for [<ReflectedDefinition>] , the F # compiler not only compiles these functions in .NET IL, but also saves its syntax representation in the DLL metadata. This view is of the type Quotations.Expr and can be restored by reflection. See Quotations.DerivedPatterns.MethodWithReflectedDefinition .

Thus, WebSharper is the source for the source translator, and it is pretty straightforward (for example, it saves lambdas). In WebSharper 2.0, we have an intermediate language like Scheme, but that only helps optimize the generated code.

+6
source

All Articles