at:tutorial:appendix
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:appendix [2008/07/10 15:29] – Added tvcutsem | at:tutorial:appendix [2008/07/10 16:02] – added tvcutsem | ||
---|---|---|---|
Line 383: | Line 383: | ||
The exception module also exports an auxiliary function '' | The exception module also exports an auxiliary function '' | ||
+ | |||
+ | ===== Language Extensions ===== | ||
+ | |||
+ | The files in the '' | ||
+ | |||
+ | ==== Futures and Multifutures ==== | ||
+ | |||
+ | === Futures === | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | The module exports the type tags '' | ||
+ | * Tagging an asynchronous message with '' | ||
+ | * Tagging a message with '' | ||
+ | * Tagging a message with '' | ||
+ | |||
+ | Messages can be automatically associated with a future by invoking the '' | ||
+ | |||
+ | The futures module also exports the function '' | ||
+ | |||
+ | Futures can also be created and resolved manually: | ||
+ | < | ||
+ | import / | ||
+ | def [fut, res] := makeFuture(); | ||
+ | when: someAsynchronousComputation() becomes: { |value| | ||
+ | res.resolve(value); | ||
+ | } | ||
+ | fut // return the future to a client | ||
+ | </ | ||
+ | |||
+ | Finally, the futures module also provides some auxiliary functions, of which '' | ||
+ | |||
+ | < | ||
+ | when: (group: [ a<-m(), b<-n() ]) becomes: { |values| | ||
+ | def [aResult, bResult] := values; | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Multifutures === | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | whenEach: multiFuture becomes: { |val| ... } | ||
+ | </ | ||
+ | |||
+ | This listener is invoked whenever the future is resolved with a new value. Its code can thus be executed multiple times. | ||
+ | |||
+ | < | ||
+ | whenAll: multiFuture resolved: { |values| | ||
+ | ... | ||
+ | } ruined: { |exceptions| ... } | ||
+ | </ | ||
+ | |||
+ | This listener invoked if all results have been gathered (only possible if the maximum number of results is known). If there are no exceptions, only the first code block is triggered. If there are only exceptions, the first block is still invoked with an empty value table. | ||
+ | |||
+ | Note the following properties of multifutures: | ||
+ | * It is allowed to register a whenAll: | ||
+ | * As with futures, it is legal to send asynchronous messages to the multifuture, | ||
+ | * When a multifuture A is resolved with a multifuture B, all of B's eventual values/ | ||
+ | * A whenEach: | ||
+ | * Like with futures, multifutures can be explicitly created, e.g.: | ||
+ | < | ||
+ | * Multifutures can be attached to messages by annotating an asynchronous message with the @Gather(n) type tag. | ||
+ | * Adding a when: | ||
+ | |||
+ | The multifutures module also exports an abstraction known as a " | ||
+ | |||
+ | When the message sent to a multireference is annotated with @Due(t), the timeout is applied to the implicit multifuture, | ||
+ | |||
+ | ==== Dynamic Variables ==== | ||
+ | |||
+ | ==== Ambient References ==== | ||
+ | |||
+ | ==== Structural Types ==== | ||
+ | |||
+ | ==== Traits ==== |
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag