Package uk.me.nxg.unity
Class FunctionDefinition
java.lang.Object
uk.me.nxg.unity.FunctionDefinition
- All Implemented Interfaces:
Comparable<FunctionDefinition>
Describes a ‘known’' function. Functions take a single unit as argument.
There are no syntax variations, beyond the set of functions which are recommended.
-
Method Summary
Modifier and TypeMethodDescriptionint
Provides a sorting order for definitions.A human-readable description of the function.boolean
A fallback name for the function.int
hashCode()
A LaTeX form of the function name.name()
The name of this function, or null.toString()
Produces a representation of this function as a string.
-
Method Details
-
description
A human-readable description of the function.- Returns:
- a string description
-
latexForm
A LaTeX form of the function name.- Returns:
- a LaTeX representation of the function
-
hashCode
public int hashCode() -
toString
Produces a representation of this function as a string. This should not generally be used for formatting expressions: for that, useUnitExpr.toString()
. -
name
The name of this function, or null. The response will be null if the function definition doesn't have enough syntax information to know what the function is called in a given syntax. The syntax in question is that associated with the function when it was parsed, which may not, of course, be the syntax associated with it when it is written.- Returns:
- a null string
-
fallbackName
A fallback name for the function.In fact, this is (a) only necessary for debugging purposes, because usually the overridden name() function will work, and (b) it is always (?) the same as the string eventually returned from name(), because (at present) all of the functions have the same short names in those syntaxes which know about them. This may be unnecessary generality (YAGNI, and all that), but it's essentially here for symmetry with the UnitDefinition lookup process, here and in ParseFunctions.java
- Returns:
- a purely text representation of the function
-
equals
-
compareTo
Provides a sorting order for definitions. The order is well-defined but is not specified here.- Specified by:
compareTo
in interfaceComparable<FunctionDefinition>
-