tupleid

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tupleid is how core tells the codec that two core.Tuple values are the same tuple in memory. codec.Measure keys its memo on it (docs/spec/ontos-codec.md §10.3).

Why this form: Go has no friend access, and core cannot import a package that names core.Tuple, because that package would import core. So the one function that reads a tuple's unexported child slice lives in core, where the compiler checks it against Tuple's fields, and core installs it in KeyOf when core is initialized. Go initializes a package before any package that imports it, so KeyOf is set before any codec code runs. The package is internal, so only this module can import it, and core's exported API is unchanged.

Index

Constants

This section is empty.

Variables

View Source
var KeyOf func(tuple any) Key

KeyOf returns the key of tuple, which must be a core.Tuple. It takes the tuple as any because this package cannot name core.Tuple. Passing the core.Value that holds the tuple converts without allocating. core sets KeyOf when it is initialized, and only the codec calls it.

Functions

This section is empty.

Types

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key identifies a tuple by its child storage: the address of its first child and its arity. Every copy of a core.Tuple shares its child slice, so all copies have one key. Two different tuples share a key only when both are empty: every empty tuple has the zero Key, and every empty tuple measures the same, so that is harmless. A non-empty tuple's key is its own, because core.NewTuple copies its children into a new slice that no other tuple holds and nothing writes to. If core ever let two tuples share a child array, keys would have to change with it.

The address is only compared, never dereferenced. Holding it as an unsafe.Pointer keeps the array alive, so the address cannot be reused while a key exists.

func Of

func Of[V any](children []V) Key

Of is the key of a tuple whose children are children. Only core calls it, with a tuple's own child slice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL