Warning: Reason support is experimental. We are looking for beta-tester and contributors. In order to use these syntax extensions, use the file extension. We provide two different syntax extensions, one based on PPX which we recommend and an older one based on Camlp4.
|Published (Last):||7 March 2011|
|PDF File Size:||3.71 Mb|
|ePub File Size:||6.31 Mb|
|Price:||Free* [*Free Regsitration Required]|
Warning: Reason support is experimental. We are looking for beta-tester and contributors. In order to use these syntax extensions, use the file extension. We provide two different syntax extensions, one based on PPX which we recommend and an older one based on Camlp4. This manual page documents our Camlp4 syntax extension. Server, client, and shared-sections make possible to write the code of the server and client parts in the same source file, and also to defined sections of the code that are common to the two sides.
Some special brackets make possible to distinguish between client and server code:. Structuring the source code of your application into client and server sections wouldn't be of much use as-is; we need a way to exchange data between these parts in a way which reflects the asymmetries between the client and the server parts, i.
This is called injecting a server value into the client:. The server side value is injected once and for all when the page is sent for the first time. There is no automatic request to the server when the client tries to access this value. In particular, if the server side value is mutable, a copy is sent to the client. On the other hand, it is possible to declare and deal with arbitrary client values in the server program.
Those are just arbitrary expressions of client-side code declared inside double curly braces:. But once it is sent to the client, it evaluates to the value of expr having type typ. In some cases where inference is not sufficient, eliomc will emit a warning indicating than this type annotation is needed. It is for example possible to inject a parameter into a request client value:.
The pattern used in this example is very common to ask the client-side program to execute a piece of code after receiving the page. Server side client values may occur in a request position, i. Or they occur either in a global position , i. All global client values are sent with the initial request of a client process. They are evaluated during the initialization of the client program, i. This is necessary in order to safely inject them into the next client-section. Thus, if you want to refer to the DOM in global client values e.
Request client values, however, are sent with the next response to the client and evaluated after setting up the possibly sent document. There are several ways how a server side client value can be sent to the client, accessing its concrete value.
Firstly, the most basic one is by just injecting it to another client value:. Then a second client of type unit value is created. Here, the second client value is ignored; however, it will be evaluated on client side, executing the side effect, just because it has been created. A very neat way to do client side programming inside the service handler! It is not possible to send values containing closures that way.
There are two executables: one server-side, and one client-side, and closures just contain a pointer to the code. Extra code is never sent dynamically over the network. This means that unforced lazy values, objects, or anything containing functions can't be sent. Functions must be defined on the side s where they will run.
Most of the time, you can do all you want by using client values or server functions. Some Eliom types use a specific mechanism to circumvent this limitation. This is the case for services, comet channels, and buses. To use this mechanism see chapter Wrapping values. Those values are typechecked "by name": the most general type of a variable is inferred for server side then use as a type constraint on client side. For instance. As client and server code are compiled separately, this means that a code like the following would be incorrect but would typecheck.
Do not read this section if you do not feel the urge to dive into the implementation details of Eliom, or if you have a weak stomach! This sections gives some details on the implementation of the language extensions in Eliom.
When a client value is then created dynamically, a client closure is registered to be sent to the client. It contains the closure ID, an instance ID unique per client value , and the tuple of injected values sometimes known as args. On the client side, that client value datum will be used to register an actual client value: A client closure is obtained by the specific closure ID, and it is applied on the tuple of injected values. Finally, the result is registered in a client value table for that specific closure ID and instance ID.
The representation of a client value on the server side is comprised just of the respective closure ID, and the instance ID.
When it reaches the client, it is unwrapped to the concrete value by looking it up in the client value table mentioned before. The usage of an injection registers the value under a specific identifier on the server side. All injections are sent to the client with the initial request as a table mapping those identifiers to untyped values.
This must be done post-hoc because client values are unwrapped late. The syntax extensions then generates for an injection just a lookup in that global table for its identifier. Type constraints are generated from the syntax extension. Version 1.
camlp4 • help
Warning: Reason support is experimental. We are looking for beta-tester and contributors. Recent versions of OCaml 4. Eliom 5. This document provides a migration guide from our older Camlp4-based language to the new PPX-based language. While our Camlp4 language is still supported, future development will focus on PPX, and therefore users are advised to migrate. For more extensive information on the PPX extension itself, refer to the corresponding manual page.
Camlp4 is a software system for writing extensible parsers for programming languages. It provides a set of OCaml libraries that are used to define grammars as well as loadable syntax extensions of such grammars. Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most important applications was the definition of domain-specific extensions of the syntax of OCaml. Its original author is Daniel de Rauglaudre. OCaml version 3.
OCPWin Installation Instructions
Eliom's Reference manual