|
|
# List of useful annotations
|
|
|
|
|
|
The goal of this page is to provide a comprehensive summary of useful message and method annotations in AmbientTalk.
|
|
|
|
|
|
# Message annotations
|
|
|
|
|
|
- `@FutureMessage` : instructs <- to return a future rather than `nil`. (implemented)
|
|
|
- `@OnewayMessage` : instructs <- to return '''nil''', even if futures are enabled by default. (implemented)
|
|
|
- `@ReturnHandle` : instructs <- to return a tuple [handle](future,). The handle has a `cancel` method that can be used to retract the message from the far ref's outbox (not yet implemented)
|
|
|
- `@Due(timeout)` : instructs <- to return a future which auto-expires (is ruined with a TimeoutException) after the given timeout period has elapsed. (implemented)
|
|
|
- `@MetaMessage` : instructs an eventual ref to dispatch the message to its mirror (the eventual ref itself) rather than to the object which it designates. (implemented, but only works for reflective eventual refs, not (yet) for native ones)
|
|
|
|
|
|
# Method annotations
|
|
|
|
|
|
- `@Required`: methods marked with `@Required` can be used to document those methods that are required by a trait from its composite. They are excluded by default when the trait in which they are defined is imported (because otherwise they could conflict with the actual implementation as provided by the composite). Moreover, we could generate the method body for these methods as being `raise: XMissingRequiredMethod.new(`methodname)`. The idea is to use this annotation as follows:
|
|
|
```
|
|
|
def EnumerableT := object: {
|
|
|
def collect: pred { ... self.each: ... }
|
|
|
def detect: pred { ... self.each: ... }
|
|
|
def each: clo @Required;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
(none of the annotations below are currently implemented)
|
|
|
|
|
|
- `@Maker` : declares the method/function to be a constructor function. It executes the function and treats the return value as the new object being made. It will automatically define a 'new' method on the returned object, whose implementation simply invokes the maker function. E.g.:
|
|
|
```
|
|
|
def createFoo(x) @Maker { object: { ... } }
|
|
|
```
|
|
|
is equivalent to:
|
|
|
```
|
|
|
def createFoo(x) { object: { def new(@args) { createFoo(@args) }; ... }
|
|
|
```
|
|
|
- `@Before` : instructs that the method performs a super-send at the end, e.g.
|
|
|
```
|
|
|
def m() @Before { ... } => def m() { ... ; super^m() }
|
|
|
```
|
|
|
- `@After` : like Before, but super-send is performed first
|
|
|
- `@Around` : like Before and After, but super-send triggered by invoking 'proceed' (can this lexical name be introduced?)
|
|
|
|
|
|
# Object annotations
|
|
|
|
|
|
- `Hashable` to indicate one can call hashCode() to get an object's hash
|
|
|
- `Printable` to indicate that one can call print() to get an object's printed representation
|
|
|
- `Comparable` to indicate that one can call `==` to compare 2 objects of this kind |