builtin — Invoke a registered builtin implementation by name.
[varargout] = builtin(name, varargin) forwards the supplied arguments and requested output count to the selected registered builtin. The target, not this dispatcher, owns input admission, numeric/storage behavior, output facts, and errors.
Syntax
[varargout] = builtin(name, varargin)Inputs
name- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Builtin function name.
varargin- Type
Any- Required
- Variadic
- Default
- —
- Description
- Builtin function arguments.
Returns
varargout- Type
Any- Description
- Output value(s) from the selected builtin implementation.
Returned values from builtin depend on how many outputs the caller requests.
Dispatch and output count
name is a scalar builtin name. Positional arguments after it are forwarded unchanged. The caller's requested output count is forwarded, including multiple outputs. The selected target determines valid arity, options, output class and shape, and failure identifiers; a source-known name alone does not prove those runtime facts for arbitrary arguments.
For subsref and subsasgn, the registered implementation executes the standard subscript descriptor, including chained member, parentheses, and brace steps. It bypasses the original receiver's indexing override while preserving member visibility, dependent-property accessors, and ordinary dispatch on nested receivers. Assignments use the shared indexing implementation rather than the public setfield extension.
Method and target calls may execute user code, mutate objects, suspend, throw, or use ambient services. An unknown or dynamically resolved target remains effectful. This wrapper is not a replay boundary for post-effect failures.
Integer and device behavior
All eight integer classes pass unchanged to an admitted target. Scalar-double mixing, overflow, output class, and computation domain are function-specific; builtin does no arithmetic or numeric conversion itself.
The selected target owns GPU/provider admission, transfers, output residency and fusion. Dispatch does not imply host-only execution or gather resident payloads merely because the target name is text. Target-specific provider capabilities and error ordering remain in force.
The wrapper is portable runtime dispatch with no separate native symbol or target-specific scheduler. Calls may reach process-stack methods and inherit their reentry, callback, ownership and affinity requirements. Distributed or foreign behavior is likewise target-dependent, not a blanket portability guarantee.
Examples
Preserve an integer target's output class
value = builtin('plus', uint64(7), uint64(3));Forward two requested outputs
[row, col] = builtin('find', [0 4; 5 0]);Using builtin with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how builtin changes the result.
Run a small builtin example, explain the result, then change one input and compare the output.
FAQ
Does builtin convert integer arguments to double?⌄
No. It forwards them unchanged; the selected builtin's integer contract applies.
Can a delegated call use a GPU provider?⌄
Yes, if the selected builtin admits that form. builtin itself neither launches a kernel nor forces a gather.
Who decides how many outputs are valid?⌄
The selected builtin receives the caller's requested output count and owns its output contract.
Related Introspection functions
addlistener · addParameter · addprop · assignin · cancel · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · eval · evalc · evalin · feval · findprop · func2str · functions · get.p · getcallinfo · getmethod · inputname · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · isvalid · keyboard · loadobj · localfunctions · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mfilename · mislocked · mlock · munlock · namelengthmax · narginchk · nargoutchk · new_object · notify · numArgumentsFromSubscript · onCleanup · parse · saveobj · set.p · stats · str2func · subsasgn · subsref · superclasses · underlyingType · verLessThan · version · which · who · whos
Source you can read
Every RunMat function's source is public. Read exactly how builtin is executed, line by line, in Rust.
- View the source for builtin in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.