new_object — Create a class instance initialized from registered property defaults.
new_object(class_name) is a RunMat object-construction entry. It creates a scalar object from the selected class registry, including inherited nonstatic default properties, but does not call a user constructor method. A class with handle ancestry returns a handle instance; an unknown valid class name produces an empty value object.
Syntax
obj = new_object(class_name)Inputs
class_name- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Class name for the object to create.
Returns
obj- Type
Any- Description
- Created class object value.
Errors
RunMat:NEW_OBJECT:Arity- When
- The number of inputs does not match the fixed signature.
- Message
new_object: expected 1 input arguments
RunMat:TooManyOutputs- When
- More than one output is requested.
- Message
new_object: at most one output is supported
Inputs and outputs
class_name accepts scalar string text or a character row. The existing runtime also formats scalar integers using exact decimal text, and scalar doubles and logicals using their legacy textual form. This formatting does not imply that the resulting text is a valid class identity. Numeric arrays and provider-resident values are not gathered.
Zero or one output is supported; the output class follows class_name. The property set and handle/value semantics depend on the selected runtime registry and cannot be inferred from the name alone.
Construction and errors
Registered class defaults are traversed root-to-leaf; static properties are omitted. Default values retain their existing shared roots. Unknown valid class identities are permitted and have no declared properties.
This helper initializes defaults only. It does not invoke class_name(args), evaluate arbitrary source, or establish a workspace variable by itself. Abstract classes reject with RunMat:AbstractMethodMissing. Malformed class names reject with RunMat:InvalidClassName; retained selected-owner mismatches and allocation failures preserve their existing diagnostics.
Execution and resource limits
The canonical binding retains its full BuiltinArguments owner and scopes the selected RuntimeContext around the existing class service. Registry reads and GC/default backing remain conservatively modeled as runtime-owned impure effects.
Cancellation and stale allocation authority are checked before text projection, scope allocation, or object construction. Finite managed construction is refused with RunMat:Placement:InsufficientResourceEvidence until registry/default/handle backing has an exact physical bound. This is not a bounded-host success claim.
Construction is host-only on native and WASM, a fusion boundary, and unsupported for distributed placement. There is no GPU provider or implicit gather.
Examples
Construct an empty instance for an unregistered class
obj = new_object('ExampleEmpty');
name = class(obj);Reject a malformed class identity
obj = new_object('bad..Class');Using new_object with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how new_object changes the result.
Run a small new_object example, explain the result, then change one input and compare the output.
FAQ
Does new_object call my constructor method?⌄
No. It initializes registered nonstatic property defaults; ordinary class construction is the route for invoking a user constructor.
Is this the MATLAB constructor API?⌄
No. This is a RunMat-native construction helper, not a claim of MATLAB new_object compatibility.
Related Introspection functions
addlistener · addParameter · addprop · assignin · builtin · 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 · 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 new_object is executed, line by line, in Rust.
- View the source for new_object 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.