applicates/internals

Source   Edit  

Types

Applicate = distinct ApplicateKey
distinct version of ApplicateKey Source   Edit  
ApplicateArg = static Applicate
static Applicate to use for types of arguments Source   Edit  
ApplicateKey = int
"pointer to" (index of) applicate AST. if you define applicatesCacheUseTable this will be a string Source   Edit  

Consts

applicateCache = "applicates.applicates"

the cache containing the routine definition nodes of each applicate. can be indexed by the ID of an applicate to receive its routine node, which is meant to be put in user code and invoked

if you define applicatesCacheUseTable then it will use a CacheTable with unique strings

Source   Edit  

Procs

proc arity(appl: Applicate): int {.compileTime, ...raises: [], tags: [],
                                   forbids: [].}
gets arity of applicate. check inferArity for meaning of negative values

Example:

import applicates, applicates/operators
doAssert static(arity((x, y) ==> x + y)) == 2
doAssert static(arity(a ==> a)) == 1
doAssert static(arity(==> 3)) == 0
Source   Edit  
proc inferArity(sym: NimNode): int {....raises: [], tags: [], forbids: [].}
infers arity of symbol
-1 if sym is not a symbol, -2 if implementation

of a symbol was nil, -3 if symbol choice arities do not match

Source   Edit  
proc node(appl: Applicate): NimNode {.compileTime, ...raises: [], tags: [],
                                      forbids: [].}
retrieves the node of the applicate from the cache Source   Edit  
proc registerApplicate(node: NimNode; num: int = applicateCount()): ApplicateKey {.
    compileTime, ...raises: [], tags: [], forbids: [].}
Source   Edit  

Templates

template applicateCount(): int
total number of registered applicates Source   Edit