Cached operations in EOL
To simulate derived properties, EOL supports cached operations. A cached operation - parameter-less operation annotated with a @cached annotation - is only executed once: subsequent calls return the same result without executing its body again. An example that calculates the Fibonacci number of a given Integer follows:
15.fib();
@cached
operation Integer fib() : Integer {
if (self = 1 or self = 0) {
return 1;
}
else {
return (self-1).fib() + (self-2).fib();
}
}