IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

RuntimeInt

struct RuntimeInt[dtype: DType = DType.int]

Runtime index value with configurable precision.

Parameters

  • dtype (DType): The data type for the runtime integer value. Defaults to DType.int.

Implemented traits

AnyType, CoordLike, Copyable, Defaultable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, TrivialRegisterPassable, Writable

comptime members

DTYPE

comptime DTYPE = dtype

The data type for the runtime integer value.

is_static_value

comptime is_static_value = False

True if the value is known at compile time.

is_tuple

comptime is_tuple = False

True if this is a tuple type (Coord), False for scalar values.

is_value

comptime is_value = True

True if this is a scalar value, False for tuple types.

ParamListType

comptime ParamListType = *?

The element types (Self for scalar types).

static_value

comptime static_value = -1

Always -1 for runtime values (not statically known).

Methods

__init__

__init__() -> Self

Initialize a runtime integer with value 0.

__init__(value: Scalar[dtype]) -> Self

Initialize a runtime integer with the given value.

Args:

__len__

static __len__() -> Int

Get the length (always 1 for scalar types).

Returns:

Int: Always returns 1.

write_to

write_to(self, mut writer: T)

Write this runtime integer to a writer.

Args:

  • writer (T): The writer to write to.

write_repr_to

write_repr_to(self, mut writer: T)

Write the repr of this runtime integer to a writer.

Args:

  • writer (T): The writer to write to.

product

product(self) -> Scalar[RuntimeInt[dtype].DTYPE]

Calculate the product (returns the value for scalar types).

Returns:

Scalar[RuntimeInt[dtype].DTYPE]: The integer value.

sum

sum(self) -> Scalar[RuntimeInt[dtype].DTYPE]

Calculate the sum (returns the value for scalar types).

Returns:

Scalar[RuntimeInt[dtype].DTYPE]: The integer value.

value

value(self) -> Scalar[RuntimeInt[dtype].DTYPE]

Get the scalar value.

Returns:

Scalar[RuntimeInt[dtype].DTYPE]: The runtime integer value.

tuple

tuple(var self) -> Coord[RuntimeInt[dtype]]

Get as a tuple (not valid for RuntimeInt).

Returns:

Coord[RuntimeInt[dtype]]: Never returns; aborts at compile time.