User Tools

Site Tools


at:tutorial:appendix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:appendix [2008/07/10 15:29] – Added tvcutsemat:tutorial:appendix [2008/07/10 15:53] – added tvcutsem
Line 383: Line 383:
  
 The exception module also exports an auxiliary function ''error(msg)'' which can be used to raise a "quick and dirty" runtime exception with a given message. It also exports the prototypes of a number of standard exceptions that can be raised by the language runtime itself. The exception module also exports an auxiliary function ''error(msg)'' which can be used to raise a "quick and dirty" runtime exception with a given message. It also exports the prototypes of a number of standard exceptions that can be raised by the language runtime itself.
 +
 +===== Language Extensions =====
 +
 +The files in the ''at/lang'' directory define custom language features which mostly use AmbientTalk/2's reflective facilities to extend the language.
 +
 +==== Futures and Multifutures ====
 +
 +=== Futures ===
 +
 +The module ''/.at.lang.futures'' provides support for futures. Futures have already been described as part of the [[concurreny|concurrency]] section in the tutorial.
 +
 +The module exports the type tags ''OnewayMessage'', ''FutureMessage'' and ''Due'':
 +  * Tagging an asynchronous message with ''FutureMessage'' will attach a future to the message.
 +  * Tagging a message with ''OnewayMessage'' ensures no future will ever be attached to the message.
 +  * Tagging a message with ''@Due(timeout)'' associates a future with the message that is automatically ruined with a ''TimeoutException'' after the given ''timeout'' period (in milliseconds) has elapsed.
 +
 +Messages can be automatically associated with a future by invoking the ''enableFutures()'' function, which enables futures for all messages, except those tagged as a ''OnewayMessage''.
 +
 +The futures module also exports the function ''when:becomes:'' to await the resolution of a future, and auxiliary ''when:becomes:catch:using:'' functions.
 +
 +Futures can also be created and resolved manually:
 +<code>
 +import /.at.lang.futures;
 +def [fut, res] := makeFuture();
 +when: someAsynchronousComputation() becomes: { |value|
 +  res.resolve(value); // resolve the future manually
 +}
 +fut // return the future to a client
 +</code>
 +
 +Finally, the futures module also provides some auxiliary functions, of which ''group:'' is often a very useful one. The ''group:'' construct groups a table of futures into a single future which is resolved with a table of values or ruined with an exception:
 +
 +<code>
 +when: (group: [ a<-m(), b<-n() ]) becomes: { |values|
 +  def [aResult, bResult] := values;
 +  ...
 +}
 +</code>
 +
 +=== Multifutures ===
 +
 +The module ''/.at.lang.multifutures'' provides support for multifutures.
 +
 +==== Dynamic Variables ====
 +
 +==== Ambient References ====
 +
 +==== Structural Types ====
 +
 +==== Traits ====
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag