For the complete documentation index, see llms.txt. This page is also available as Markdown.

4n: Virtualization

+mack

Nock subject to +unit.

Accepts a Nock subject-formula cell and wraps it into a +unit. .fol is pure Nock, meaning that Nock 11 operations result in a block, producing a ~.

Accepts

.sub is a subject $noun.

.fol is a formula $noun, which is generally a $nock.

Produces

The +unit of a $noun.

Source

++  mack
  |=  [sub=* fol=*]
  ^-  (unit)
  =/  ton  (mink [sub fol] ~)
  ?.(?=(%0 -.ton) ~ `product.ton)

Examples

> (mack [[1 2 3] [0 1]])
[~ [1 2 3]]

+mink

Mock interpreter.

Bottom-level mock (virtual Nock) interpreter. Produces a $tone, a Nock computation result. If Nock 12 is invoked, +scry computes on the subject and produces a (unit (unit)) result. An empty result becomes a %1 $tone, indicating a block.

The Nock specification defines 12 operations 0-11, plus an autocons operation. However, every practical Nock interpreter implements a 13th operation, "Nock 12." This "Nock" operation is the compilation target for the .^ (dotket) rune in Hoon.

+mink is described as a "Mock" interpreter. Mock is just Nock extended with Nock 12. In order to interpret opcode 12, +mink takes as an argument, in addition to the subject and formula, a gate which will be invoked with the results of the subformulas of 12 as a sample. The result of executing this gate (not as interpreted by +mink but by whichever interpreter is running +mink) are then treated as the result of the Nock 12 operation.

This is the manner in which Urbit's namespace is implemented. Applications with access to the scry namespace are run within +mink, and the gate simply computes the scry namespace.

Since +mink is a Nock (Mock) interpreter written in Nock, it can report when a Nock computation crashes deterministically (i.e. when the specification requires a crash). This provides a way to handle errors in applications without needing to depend on the runtime to re-inject the error as a new event.

Note that the gate is expected to return a result of type (unit (unit)). A null value for the outer +unit means "blocked": +mink will report that data required by a 12 was not available. A null value for the inner +unit ([~ ~]) means that the requested read will never be available and +mink will instead report that the computation crashed in the same manner as any other crashing Nock computation.

+mink is jetted by practical Nock interpreters. The jet is just the interpreter itself. This provides zero-cost virtualization of Nock or Mock computation as a Hoon standard library function.

Accepts

.subject is the subject as a $noun.

.formula is the formula as a $noun.

+scry is either ~, or an %iron gate invoked with Nock operator 12.

Passing ~ means "no scry handler is available". A formula that never performs a Nock 12 evaluates normally; one that does immediately produces [%2 trace], the same block result as an unavailable read. For example:

Produces

A $tone.

Source

Examples


+mock

Compute formula on subject with hint.

Produces a $toon, which is either a sucessful, blocked, or crashed result. If Nock 12 is invoked, .gul computes on the subject and produces a (unit (unit)) result. An empty result becomes a %1 $tune, indicating a block.

Accepts

.sub is the subject as a $noun.

.fol is the formula as a $noun.

.gul is an %iron gate invoked with Nock operator 11.

Produces

The +unit of a $noun.

Source

Examples


+mook

Intelligently render crash annotation.

Converts a %2 $tone Nock stack trace to a list of $tank. Each may be a $tank, $cord, +spot, or trapped $tank.

Accepts

.ton is a $tone.

Produces

A $toon.

Source

Examples


+vi

Virtualization door.

Container door for the virtualization arms +mole, +mule, +mure and +mute. Its sample .for controls whether a scry (Nock 12) performed inside the virtualized computation is forwarded to the real namespace.

Accepts

.for is a ?.

Source

Discussion

When .for is true, the arms build a scry handler and pass it to +mink/+mock; when it is false they pass ~, the "no scry handler" sentinel, so any Nock 12 inside blocks and the computation reports failure.

The default forwards. .for is a ?, whose bunt is %.y, so mure:vi and the bare aliases forward scries. Pass | explicitly to prevent that:

Only +mole and +mule have top-level aliases (++ mole mole:vi, ++ mule mule:vi). +mure and +mute must be reached through the door.


+mole

Typed unitary virtual.

Kicks a +trap, producing its result in a +unit if successful, or a null +unit if it crashed. Unitized version of +mule.

Accepts

+tap is a +trap.

Produces

A (unit *), where the * will be the type produced by the expression.

Source

Examples


+mong

Slam gate with sample.

Produces a $toon computation result from slamming .gat with .sam, using .gul to compute or block on Nock 12 when applicable.

Accepts

.gat is a $noun that is generally a $gate.

.sam is a sample $noun.

.gul is an %iron gate invoked with Nock operator 11.

Produces

A $toon.

Source

Examples


+mule

Typed virtual.

Kicks a +trap, producing its results or any errors that occur along the way. Used to lazily compute stack traces.

Accepts

.tap is a +trap, generally producing a list of $tanks.

Produces

An (each * (list tank)) - %.y indicates success and %.n indicates a crash.

Source

Examples


+mure:vi

Untyped unitary virtual.

Kicks a +trap, producing its results in a +unit which is null if it crashed. The result is just a $noun, no type information is preserved.

Note. +mure is no longer a top-level arm. It lives in the +vi door, and a bare (mure ...) fails with -find.mure. Use mure:vi, or ~(mure vi for) to control namespace forwarding.

Accepts

A +trap.

Produces

A (unit *).

Source

Examples


+mute:vi

Untyped virtual.

Kicks a +trap, producing its result as a $noun or the tanks of any error that occurs. Similar to +mule, but preserves no type information.

Note. +mute is no longer a top-level arm. It lives in the +vi door, and a bare (mute ...) fails with -find.mute. Use mute:vi, or ~(mute vi for) to control namespace forwarding.

Accepts

+tap is a +trap.

Produces

A (each * (list tank)), where %.y indicates success and %.n indicates failure.

Source

Examples


+slum

Slam a gate on a sample using raw Nock, untyped.

Slam .gat with .sam. Uses a raw .* Nock expression internally and does not preserve type information for the result. This will crash if evaluation crashes.

Examples


+soft

Virtual clam.

Clam (mold) $noun .fud with $mold .han, producing a +unit of the result. The +unit is null if clamming failed. This is curried, so the soft-clamming gate can be stored and called repeatedly.

Accepts

.han is a $mold.

.fud is a $noun.

Produces

A (unit *), where the * will be the type produced by the mold.

Source

Examples


Last updated