5.3. Comparisons and orderings

The CMP module holds comparisons: it writes lexicographic orderings from a list of keys. The [ordered] structure annotation generates the structure’s operator <, so sort and everything else that compares with < orders it by default; the cmp_by call macro writes a comparator block for one call, with each key an expression over _, the element, and a leading - for descending order.

All functions and symbols are in “cmp” module, use require to get access to it.

require daslib/cmp

5.3.1. Call macros

cmp_by

Function annotation cmp_by

5.3.2. Structure macros

ordered

Structure annotation ordered

5.3.3. Classes

OrderedMacro : AstStructureAnnotation

class OrderedMacro

OrderedMacro.apply(st: StructurePtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string ): bool

def apply : function<(var self:ast::AstStructureAnnotation;var st:ast_core::Structure? aka StructurePtr -const;var group:rtti_core::ModuleGroup -const;var args:rtti_core::AnnotationArgumentList -const;var errors:$::das_string -const):bool>

Arguments:
CmpByMacro : AstCallMacro

class CmpByMacro

CmpByMacro.visit(prog: ProgramPtr; mod: Module?; expr: ExprCallMacro? ): ExpressionPtr

def visit : function<(var self:ast::AstCallMacro;prog:smart_ptr<rtti_core::Program> aka ProgramPtr const;mod:rtti_core::Module? const;expr:ast_core::ExprCallMacro? const):ast_core::Expression? aka ExpressionPtr>

Arguments:
CmpByMacro.canVisitArgument(expr: ExprCallMacro?; argIndex: int ): bool

def canVisitArgument : function<(var self:ast::AstCallMacro;expr:ast_core::ExprCallMacro? const;argIndex:int const):bool>

Arguments: