Annotation Interface Fallback
A method annotated with Fallback is treated as a Specialization that implicitly
links all the guards of all other declared Specialization annotated methods of the
operation in a negated form. As a consequence it cannot declare any other guards. The expected
signature of the method must match to the signature of a Specialization with the
additional limitation that only generically executable argument types are allowed. A generically
executable argument is an argument that can be executed from the child Node using an
execute method without UnsupportedOperationException. In many cases the generically
executable type is Object. An operation is limited to just one Fallback
specialization which is always ordered at the end of the specialization chain.
A simple example showing the use of the Fallback annotation in a DSL operation:
@Specialization int doInt(int a) {..}
@Specialization int doDouble(double a) {..}
@Fallback int orElse(Object a) {..}
The previous example could be redeclared just using Specialization annotated methods as
follows:
@Specialization int doInt(int a) {..}
@Specialization int doDouble(double a) {..}
@Specialization(guard={"!isInt(a)", "!isDouble(a)"})
int orElse(Object a) {..}
Performance note: For operations with a lot of Specialization annotated methods
the use of Fallback might generate a guard that is very big. Try to avoid the use of
Fallback for specializations that are significantly important for peak performance.
Cached, Bind and dispatched
CachedLibrary.- Since:
- 0.8 or earlier
- See Also: