RawPointer
public struct RawPointer { /* private fields */ }Untyped pointer to raw memory — void* in C terms.
Used at FFI boundaries and as an intermediate when casting between
typed pointers. RawPointer deliberately exposes no read/write methods
of its own; cast to Pointer[T] first via cast[T](). Equality and
hashing are address-based.
Examples
let p = RawPointer.nullPointer();
p.isNull // true
let typed: Pointer[Int64] = p.cast[Int64]()
Representation
One lang.ptr[lang.i8]. FFI-safe — passes as a single machine pointer.
Properties
public var address: UInt64 { get }
public var address: UInt64 { get }Numeric address of the pointee. Round-trips through
RawPointer(address:).
public var isNull: Bool { get }
public var isNull: Bool { get }Convenience for address == 0.
public var raw: lang.ptr[lang.i8]
public var raw: lang.ptr[lang.i8]The wrapped primitive i8*.
Initializers
public init(address: UInt64)
public init(address: UInt64)Reconstructs a pointer from a numeric address. Useful for platform-specific encodings (handles, MMIO addresses); incorrect addresses produce a pointer that dereferences to undefined memory.
public init(raw: lang.ptr[lang.i8])
public init(raw: lang.ptr[lang.i8])Wraps an existing primitive pointer.
Methods
public func cast[T]() -> Pointer[T] where T: not Copyable
public func cast[T]() -> Pointer[T] where T: not CopyableReinterprets the address as a Pointer[T].
Safety
The caller must ensure the address holds a valid T (correct size,
alignment, and initialised contents) before reading through the
returned pointer.
public static func nullPointer() -> RawPointer
public static func nullPointer() -> RawPointerReturns the canonical null pointer.
public func offset(by: Int64) -> RawPointer
public func offset(by: Int64) -> RawPointerAdds bytes to the address (no element-size scaling — this is
raw byte arithmetic). Use Pointer[T].offset for element-typed
strides.
ImplementsEquatable
Associated Types
type Output = Bool
type Output = BoolMethods
public func equal(to: Self) -> Bool
public func equal(to: Self) -> BoolBridges Equal.equal(to:) to Equatable.isEqual(to:).
public func isEqual(to: RawPointer) -> Bool
public func isEqual(to: RawPointer) -> BoolAddress-based equality. Two RawPointers pointing into different
allocations are equal iff their addresses coincide.
public func notEqual(to: Self) -> Bool
public func notEqual(to: Self) -> BoolDefault !=: delegates to == so there's a single source of truth.
ImplementsHashable
Methods
public func hash[H](into: mutating H) where H: Hasher
public func hash[H](into: mutating H) where H: HasherHashes the underlying address.
Heap allocations cluster on alignment boundaries, so the raw
address has predictable low bits. We run the address through
Murmur3's fmix64 finalizer (two rounds of xor-shift / multiply) before hashing so every input bit avalanches across
the 64-bit output. Without this, pointer-keyed maps see
collision clustering driven by the allocator's stride.
Defined in lang/std/memory/pointer.ks