dispatch

fnauto dispatch(alias kernel, Args...)(DataType dtype, Args args)

Calls kernel!K(args) for the runtime kind of dtype, through a final switch with exactly one textual call site inside a static foreach over Kinds.

The five rules every kernel passed to dispatch obeys (verified by probes/facts 1 and 2; ../ddn/doc/DDN-TYPES.md records the general convention):

  1. Arguments are passed by value. auto ref on the dispatch

    signature would make the template impossible to name (cannot explicitly instantiate template function with 'auto ref' parameter).

  2. One erased return type per kernel: every instantiation for all

    fourteen kinds must return the same type (ArrayData, size_t, ...). A kernel constrained to a subset of kinds, or returning different types per kind, does not compile — use dispatchNumeric, an unsupported!K branch, or (for aggregations, whose result dtype depends on the kind) a one-slot ArrayData of the promoted dtype read out afterwards.

  3. Kernels are module-level templates. A local (nested) template

    kernel is rejected, so no closure is ever heap-allocated through dispatch; user callbacks travel as runtime scope delegate arguments.

  4. Binary operations cast both operands to the supertype first

    (ddn.columnar.types.supertypeOf) and dispatch once: fourteen instantiations per operation, not 196.

  5. Attribute contracts are pinned by attributed unittests calling

    the kernels through dispatch, never by taking &dispatch.

Parameters

kernela module-level template with a Kind value parameter
dtypethe dtype whose kind selects the instantiation
argsforwarded by value to the kernel

Returns

whatever kernel!K returns (one type for all kinds).