nupp

nupp is an always available global table that declares the Nupp standard library. It's available without a require.

-- You can use nupp and nested modules without any `require` statements.
local text = nupp.codec.json.encode({ok = true})

nupp.log.info("wrote %d bytes", #text)

nupp and nested submodules within it are available using sub-property access without the need to require anything. Submodules are loaded lazily on first access.

See Standard library for what belongs here and what does not, and Modules for how a declared module is reached.

Submodules

ModuleDescription
nupp.benchMeasuring Nupp code from inside an ordinary program.
nupp.checksumNumeric checksums, for noticing that bytes got corrupted.
nupp.cliCommand-line arguments, from raw tokens up to a whole application.
nupp.codec4 modules
nupp.compressionCompressing and decompressing a stream of bytes.
nupp.deriveGenerates checked members on a declaration while that declaration is checked.
nupp.digestCryptographic hashes: SHA-256 and the rest.
nupp.eventsAddressed, synchronous events whose payloads are ordinary declarations.
nupp.gpunupp.gpu manages resident compute buffers over the selected GPU provider.
nupp.hostnupp.host asks whatever is running the program for something and waits for the answer: the page's JavaScript in a...
nupp.hotreloadCooperative development hot reload, installed by nupp run --watch.
nupp.ionupp.io is bytes: storage for them, and the readers and writers that move them.
nupp.lognupp.log is leveled logging whose disabled path is the one it is designed around.
nupp.macKeyed hashes, for bytes somebody could have tampered with.
nupp.mathnupp.math adds the scalar, fixed-width and two-dimensional operations missing from Lua's built-in math table.
nupp.memC storage, and the checked views that make a raw pointer safe to index.
nupp.pegnupp.peg compiles textual parsing-expression grammars into reusable typed matchers.
nupp.profileTwo profiling channels: one for where the time went, one for whether it went there compiled.
nupp.randomnupp.random provides unpredictable bytes and reproducible sequences.
nupp.reflectSemantic type reflection and reflection-driven field codecs.
nupp.serdeA binding selects how a value is read and constructed, separately from the codec that chooses its wire representation.
nupp.simdExplicit SIMD support.
nupp.spiDiscover implementations, then choose with ordinary module initialization code.
nupp.suspensionWaiting without blocking the thread.
nupp.systemnupp.system reports four fixed ABI facts and estimates available parallelism.
nupp.tasksStructured concurrency: a scope owns the tasks spawned into it.
nupp.testAssertions, for Nupp's own test runner and for project suites.
nupp.textWorking with text a byte at a time.
nupp.timenupp.time provides clocks and waits from the current host.
nupp.typesCompiler-only type inspection and construction inside @comptime function declarations.
nupp.utilSmall types that belong to no larger facility.
nupp.workersRuns functions in parallel, on real threads.

Module contents

Types

TypeKindDescription
AffineinterfaceDeclares a consuming cleanup for an affine owner.
AliasErrorrecordA failed operation on a managed alias.
CloseableinterfaceA resource with a deterministic, consuming close operation.
CopyableinterfaceA value that carries neither an ownership obligation nor a scoped borrow.
DebuginterfaceValues with deterministic compiler-generated debug formatting.
ManagedGroupinterfaceA runtime-sized heterogeneous owner group.

Types#

Affineinterface#

interface nupp.Affine<const cleanup: function>

Declares a consuming cleanup for an affine owner.

Type parameters

NameDescription
cleanup

AliasErrorrecord#

record nupp.AliasError ...

A failed operation on a managed alias.

Members

NameKindDescription
codefield
messagefield

codefield#

code: string

messagefield#

message: string

Closeableinterface#

interface nupp.Closeable is nupp.Affine<self.close> ...

A resource with a deterministic, consuming close operation.

Declaring is nupp.Closeable makes construction and bare type annotations carry the close obligation automatically. A resource that publishes pending work declares flush on its own contract; closing is the lifecycle common to all resources.

Members

NameKindDescription
closemethod

closemethod#

close: function(takes self: nupp.Closeable): nil
Arguments
NameTypeDescription
takes selfnupp.Closeable
Returns
TypeDescription
nil

Copyableinterface#

interface nupp.Copyable

A value that carries neither an ownership obligation nor a scoped borrow. Use this bound when a generic cache must return the same value repeatedly.

Debuginterface#

interface nupp.Debug ...

Values with deterministic compiler-generated debug formatting.

Members

NameKindDescription
debugmethod

debugmethod#

debug: function(self): string
Arguments
NameTypeDescription
?self
Returns
TypeDescription
string

ManagedGroupinterface#

interface nupp.ManagedGroup is nupp.Closeable ...

A runtime-sized heterogeneous owner group.

managedGroup adopts independently managed cells and closes every remaining resource in reverse adoption order. It is ordinary library code over aliases; the compiler does not give the group special ownership privileges.

Members

NameKindDescription
flushmethodCells publish no pending data of their own.
adoptmethodMoves a managed cell into the group and returns its checked non-owning alias.
removemethodRemoves an adopted alias and restores its exact original owner.

flushmethod#

flush: function(exclusive self: nupp.ManagedGroup): nil

Cells publish no pending data of their own. Their payloads decide what close publishes.

Arguments
NameTypeDescription
exclusive selfnupp.ManagedGroup
Returns
TypeDescription
nil

adoptmethod#

adopt: function<T>(exclusive self: nupp.ManagedGroup, takes cell: managed(T)): alias(T)

Moves a managed cell into the group and returns its checked non-owning alias.

Arguments
NameTypeDescription
exclusive selfnupp.ManagedGroup
takes cellmanaged(T)
Returns
TypeDescription
alias(T)

removemethod#

remove: function<T>(exclusive self: nupp.ManagedGroup, handle: alias(T)): T

Removes an adopted alias and restores its exact original owner.

Arguments
NameTypeDescription
exclusive selfnupp.ManagedGroup
handlealias(T)
Returns
TypeDescription
T