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:19] – added tvcutsem | at:tutorial:appendix [2008/07/10 15:53] – added tvcutsem | ||
---|---|---|---|
Line 344: | Line 344: | ||
The above code defines an isolate object '' | The above code defines an isolate object '' | ||
+ | |||
+ | ===== Custom Exceptions ===== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | deftype FooException; | ||
+ | </ | ||
+ | |||
+ | Next, define a prototype exception object using the '' | ||
+ | |||
+ | < | ||
+ | def XFooException := createException(FooException); | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | < | ||
+ | raise: XFooException.new(" | ||
+ | </ | ||
+ | |||
+ | If your custom exception requires additional state, you can define it as an extension of the prototype exception. If you define a custom constructor, | ||
+ | |||
+ | < | ||
+ | deftype IndexOutOfBounds; | ||
+ | def XIndexOutOfBounds := createException(IndexOutOfBounds) with: { | ||
+ | def min; | ||
+ | def max; | ||
+ | def idx; | ||
+ | def init(min, max, idx) { | ||
+ | super^init(" | ||
+ | self.min := min; | ||
+ | self.max := max; | ||
+ | self.idx := idx; | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 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 ''/ | ||
+ | |||
+ | ==== Dynamic Variables ==== | ||
+ | |||
+ | ==== Ambient References ==== | ||
+ | |||
+ | ==== Structural Types ==== | ||
+ | |||
+ | ==== Traits ==== |
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag