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 16:32] – * tvcutsem | at:tutorial:appendix [2009/01/30 16:21] – *minor tvcutsem | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Appendix ====== | + | ====== Appendix: Libraries |
In the appendix, we explain useful libraries available to the AmbientTalk/ | In the appendix, we explain useful libraries available to the AmbientTalk/ | ||
Line 82: | Line 82: | ||
It is also possible to use '' | It is also possible to use '' | ||
+ | |||
+ | <note tip> | ||
+ | See the [[distribution# | ||
+ | </ | ||
==== Test Suites ==== | ==== Test Suites ==== | ||
Line 462: | Line 466: | ||
When the message sent to a multireference is annotated with @Due(t), the timeout is applied to the implicit multifuture, | When the message sent to a multireference is annotated with @Due(t), the timeout is applied to the implicit multifuture, | ||
+ | |||
+ | ==== Leased Object References ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | The implementation of leased object references actually consists of two files: ''/ | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Variations of these constructs are also provided to allow developers to specify the renewal time interval in renew-on-call leased references and the name(s) of the method(s) which trigger expiration of a single-call leased reference. | ||
+ | |||
+ | The '' | ||
+ | |||
+ | < | ||
+ | renew: leasedRef for: interval; // renews a lease | ||
+ | revoke: leasedRef; // revokes a lease | ||
+ | leaseTimeLeft: | ||
+ | when: lease expired: {...}; // trigger a closure when the lease expires | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | Finally, the '' | ||
+ | |||
+ | |||
+ | |||
==== Dynamic Variables ==== | ==== Dynamic Variables ==== | ||
Line 542: | Line 577: | ||
==== Traits ==== | ==== Traits ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | Using the '' | ||
+ | |||
+ | To define a " | ||
+ | < | ||
+ | trait: { | ||
+ | ... | ||
+ | } requiring: Protocol; | ||
+ | </ | ||
+ | |||
+ | The above code creates a trait that can only be composed into an object adhering to the specified protocol. To compose traits, use the following language construct: | ||
+ | |||
+ | < | ||
+ | object: { | ||
+ | use: { | ||
+ | import T1 exclude ...; | ||
+ | import T2 alias ...; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | Note that the place where '' | ||
+ | |||
+ | Usage examples can be found in the unit tests in the file '' | ||
+ | |||
+ | ===== Utilities ===== | ||
+ | |||
+ | The files in the '' | ||
+ | |||
+ | ==== Timing Utilities ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | def subscription := when: timeoutPeriod elapsed: { | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | The milliseconds used to define the timeout period must be provided as a Java '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | The timer module also defines a function '' | ||
+ | |||
+ | The timer module defines a small number of additional utility functions which can be found in the file '' | ||
+ | |||
+ | ==== Logging Framework ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | Here's a typical example of how to use a logger: | ||
+ | < | ||
+ | import / | ||
+ | def log := makeLogger(" | ||
+ | log("a message", | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | The logging level determines which messages are shown on the output log. The available error levels are: '' | ||
+ | |||
+ | The output object is an object that understands '' | ||
+ | |||
+ | ==== Object Inspector ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | import / | ||
+ | inspect(o); | ||
+ | </ | ||
+ | |||
+ | This will pop up a graphical inspector on the object, listing the object' | ||
+ | |||
+ | ==== Symbiosis Utilities ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | < | ||
+ | long(anAmbientTalkNumber) -> aJavaLong | ||
+ | short(anAmbientTalkNumber) -> aJavaShort | ||
+ | float(anAmbientTalkFraction) -> aJavaFloat | ||
+ | byte(anAmbientTalkNumber) -> aJavaByte | ||
+ | </ | ||
+ | |||
+ | The module also defines the following function: | ||
+ | < | ||
+ | cast: obj into: Interface | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ==== Miscellaneous ==== | ||
+ | |||
+ | The module ''/ | ||
+ | |||
+ | === Random Numbers === | ||
+ | |||
+ | The utility module defines functions for easily generating random numbers. Its implementation uses the random number generators from the underlying JVM. The following functions are the most useful: | ||
+ | |||
+ | < | ||
+ | // generate a random integer in the interval [min, max[ | ||
+ | def randomNumberBetween(min, | ||
+ | // generate a random fraction in the interval [min, max[ | ||
+ | def randomFractionBetween(min, | ||
+ | </ | ||
+ | |||
+ | === Custom Object Serialization === | ||
+ | |||
+ | The method '' | ||
+ | |||
+ | < | ||
+ | //inside a mirror | ||
+ | def instancevar := ...; | ||
+ | def pass() { | ||
+ | uponArrivalBecome: | ||
+ | // return object to become here | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The function plays a role similar to '' |
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag