Decorators
Decorators modify the default semantics of a piece of code. Decorators come in two forms:
@name_of_decorator@name_of_decorator("Some string")
The most common use of a decorator is to denote an entrypoint.
Decorators are placed immediately before the code they apply to. You can also apply multiple decorators to the same piece of code, as in this example:
type storage = int;
type result = [list<operation>, storage];
// @entry
// @no_mutation
const sub = (delta: int, storage: storage) : result =>
[[], storage - delta];
Decorators must be in comments unless they are within a class. For example, this class has decorators that are not in comments:
class Counter {
@entry
@inline
add = (value: int, storage: storage): result =>
[[], storage + value];
@entry
@deprecated
sub = (value: int, storage: storage): result =>
[[], storage - value];
@view
get = (_: unit, storage: storage): storage => storage;
}
List of decorators
LIGO supports these decorators: