Urbit Developers
  • Hoon

    • Overview
    • Cheat Sheet
    • Irregular forms
    • Hoon Errors
    • Hoon Style Guide
    • Basic Types
    • Advanced Types
    • Auras
    • Standard Library

      • 1a: Basic Arithmetic
      • 1b: Tree Addressing
      • 1c: Molds and Mold-Builders
      • 2a: Unit Logic
      • 2b: List Logic
      • 2c: Bit Arithmetic
      • 2d: Bit Logic
      • 2e: Insecure Hashing
      • 2f: Noun Ordering
      • 2g: Unsigned Powers
      • 2h: Set Logic
      • 2i: Map Logic
      • 2j: Jar and Jug Logic
      • 2k: Queue Logic
      • 2l: Container from Container
      • 2m: Container from Noun
      • 2n: Functional Hacks
      • 2o: Normalizing Containers
      • 2p: Serialization
      • 2q: Molds and Mold-Builders
      • 3a: Modular and Signed Ints
      • 3b: Floating Point
      • 3c: Urbit Time
      • 3d: SHA Hash Family
      • 3e: AES encryption (Removed)
      • 3f: Scrambling
      • 3g: Molds and Mold-Builders
      • 4a: Exotic Bases
      • 4b: Text Processing
      • 4c: Tank Printer
      • 4d: Parsing (Tracing)
      • 4e: Parsing (Combinators)
      • 4f: Parsing (Rule-Builders)
      • 4g: Parsing (Outside Caller)
      • 4h: Parsing (ASCII Glyphs)
      • 4i: Parsing (Useful Idioms)
      • 4j: Parsing (Bases and Base Digits)
      • 4k: Atom Printing
      • 4l: Atom Parsing
      • 4m: Formatting Functions
      • 4n: Virtualization
      • 4o: Molds
      • 5a: Compiler Utilities
      • 5b: Macro Expansion
      • 5c: Compiler Backend & Prettyprinter
      • 5d: Parser
      • 5e: Molds and mold builders
      • 5f: Profiling support
      • Runes

        • Atoms and strings
        • Nock . ('dot')
        • Wild ! ('zap')
        • Change Subject = ('tis')
        • Conditionals ? ('wut')
        • Cores | ('bar')
        • Arms + ('lus')
        • Cells : ('col')
        • Calls % ('cen')
        • Casts ^ ('ket')
        • Structures $ ('buc')
        • Make ; ('mic')
        • Hints ~ ('sig')
        • Imports / ('fas')
        • Terminators -- and ==
        • Limbs and wings

          • Limbs
          • Wings
          • Zuse

            • Table of Contents
            • 2d(1-5): To JSON, Wains
            • 2d(6): From JSON
            • 2d(7): From JSON (unit)
            • 2e(2-3): Print & Parse JSON
          • Arvo

            • Overview
            • Ames

              • Overview
              • Cryptography
              • API Reference
              • Scry Reference
              • Data Types
              • Behn

                • Overview
                • API Reference
                • Scry Reference
                • Examples
                • Clay

                  • Overview
                  • Architecture
                  • Using Clay
                  • Data Types
                  • Scry Reference
                  • API Reference
                  • Examples
                  • Marks

                    • Overview
                    • Writing Marks
                    • Using Marks
                    • Examples
                  • Dill

                    • Overview
                    • API Reference
                    • Scry Reference
                    • Data Types
                    • Eyre

                      • Overview
                      • External API Reference
                      • Internal API Reference
                      • Scry Reference
                      • Data Types
                      • Guide
                      • Gall

                        • Overview
                        • API Reference
                        • Data Types
                        • Threads Reference
                        • Iris

                          • Overview
                          • API Reference
                          • Data Types
                          • Example
                          • Jael

                            • Overview
                            • API Reference
                            • Scry Reference
                            • Data Types
                            • Examples
                            • Threads

                              • Overview
                              • HTTP API
                              • Reference
                              • Gall

                                • Start Thread
                                • Take Result
                                • Take Facts
                                • Stop Thread
                                • Poke Thread
                                • Examples

                                  • Fetch JSON
                                  • Child Thread
                                  • Main-loop
                                  • Poke Agent
                                  • Scry
                                  • Take Fact
                                • Concepts

                                  • Scries
                                  • Subscriptions
                                  • Tutorials

                                    • Move Trace
                                    • Reference

                                      • Cryptography
                                      • Filesystem Hierarchy
                                    • Nock

                                      • Nock Definition
                                      • Explanation
                                      • Example
                                      • Implementations
                                      • Vere

                                        • C Runtime System
                                        • Land of Nouns
                                        • API overview by prefix
                                        • C in Urbit
                                        • Writing Jets
                                        • Cryptography
                                        • Azimuth

                                          • Overview
                                          • Urbit HD Wallet
                                          • Azimuth Data Flow
                                          • Azimuth.eth
                                          • Ecliptic.eth
                                          • Advanced Azimuth Tools
                                          • Life and Rift
                                          • Layer 2

                                            • Layer 2 Overview
                                            • Layer 2 Actions
                                            • Transaction Format
                                            • Rollers
                                            • Roller HTTP RPC-API
                                            • Custom Roller Tutorial
                                          • Glossary

                                            • Ames
                                            • Aqua
                                            • Arm
                                            • Arvo
                                            • Atom
                                            • Azimuth
                                            • Battery
                                            • Behn
                                            • Bridge
                                            • Censures
                                            • chat
                                            • Claims
                                            • Clay
                                            • Comet
                                            • Core
                                            • Delegated Sending
                                            • Desk
                                            • Dill
                                            • Document Proposal
                                            • Dojo
                                            • Door
                                            • Ecliptic
                                            • Event Log
                                            • Eyre
                                            • Galaxy
                                            • Gall
                                            • Gate
                                            • HD Wallet
                                            • Hoon
                                            • Invite Tree
                                            • Iris
                                            • Jael
                                            • Keyfile
                                            • Khan
                                            • Landscape
                                            • Mark
                                            • Moon
                                            • Nock
                                            • Noun
                                            • OTA Updates
                                            • Payload
                                            • pH
                                            • Pier
                                            • Pill
                                            • Planet
                                            • Proxies
                                            • Replay
                                            • Factory Reset
                                            • Naive rollups
                                            • Sail/Udon
                                            • Senate
                                            • Ship
                                            • ship.arvo.network
                                            • Star
                                            • |sync
                                            • Trap
                                            • Upgrade Proposal
                                            • Vane
                                            • Vere
                                            • Voting
                                            • Wallet-Generator
                                            • Additional

                                              • Cryptography
                                              • Software Distribution

                                                • Overview
                                                • Docket File
                                                • Glob
                                              Urbit Developers
                                              • Hoon

                                                • Overview
                                                • Cheat Sheet
                                                • Irregular forms
                                                • Hoon Errors
                                                • Hoon Style Guide
                                                • Basic Types
                                                • Advanced Types
                                                • Auras
                                                • Standard Library

                                                  • 1a: Basic Arithmetic
                                                  • 1b: Tree Addressing
                                                  • 1c: Molds and Mold-Builders
                                                  • 2a: Unit Logic
                                                  • 2b: List Logic
                                                  • 2c: Bit Arithmetic
                                                  • 2d: Bit Logic
                                                  • 2e: Insecure Hashing
                                                  • 2f: Noun Ordering
                                                  • 2g: Unsigned Powers
                                                  • 2h: Set Logic
                                                  • 2i: Map Logic
                                                  • 2j: Jar and Jug Logic
                                                  • 2k: Queue Logic
                                                  • 2l: Container from Container
                                                  • 2m: Container from Noun
                                                  • 2n: Functional Hacks
                                                  • 2o: Normalizing Containers
                                                  • 2p: Serialization
                                                  • 2q: Molds and Mold-Builders
                                                  • 3a: Modular and Signed Ints
                                                  • 3b: Floating Point
                                                  • 3c: Urbit Time
                                                  • 3d: SHA Hash Family
                                                  • 3e: AES encryption (Removed)
                                                  • 3f: Scrambling
                                                  • 3g: Molds and Mold-Builders
                                                  • 4a: Exotic Bases
                                                  • 4b: Text Processing
                                                  • 4c: Tank Printer
                                                  • 4d: Parsing (Tracing)
                                                  • 4e: Parsing (Combinators)
                                                  • 4f: Parsing (Rule-Builders)
                                                  • 4g: Parsing (Outside Caller)
                                                  • 4h: Parsing (ASCII Glyphs)
                                                  • 4i: Parsing (Useful Idioms)
                                                  • 4j: Parsing (Bases and Base Digits)
                                                  • 4k: Atom Printing
                                                  • 4l: Atom Parsing
                                                  • 4m: Formatting Functions
                                                  • 4n: Virtualization
                                                  • 4o: Molds
                                                  • 5a: Compiler Utilities
                                                  • 5b: Macro Expansion
                                                  • 5c: Compiler Backend & Prettyprinter
                                                  • 5d: Parser
                                                  • 5e: Molds and mold builders
                                                  • 5f: Profiling support
                                                  • Runes

                                                    • Atoms and strings
                                                    • Nock . ('dot')
                                                    • Wild ! ('zap')
                                                    • Change Subject = ('tis')
                                                    • Conditionals ? ('wut')
                                                    • Cores | ('bar')
                                                    • Arms + ('lus')
                                                    • Cells : ('col')
                                                    • Calls % ('cen')
                                                    • Casts ^ ('ket')
                                                    • Structures $ ('buc')
                                                    • Make ; ('mic')
                                                    • Hints ~ ('sig')
                                                    • Imports / ('fas')
                                                    • Terminators -- and ==
                                                    • Limbs and wings

                                                      • Limbs
                                                      • Wings
                                                      • Zuse

                                                        • Table of Contents
                                                        • 2d(1-5): To JSON, Wains
                                                        • 2d(6): From JSON
                                                        • 2d(7): From JSON (unit)
                                                        • 2e(2-3): Print & Parse JSON
                                                      • Arvo

                                                        • Overview
                                                        • Ames

                                                          • Overview
                                                          • Cryptography
                                                          • API Reference
                                                          • Scry Reference
                                                          • Data Types
                                                          • Behn

                                                            • Overview
                                                            • API Reference
                                                            • Scry Reference
                                                            • Examples
                                                            • Clay

                                                              • Overview
                                                              • Architecture
                                                              • Using Clay
                                                              • Data Types
                                                              • Scry Reference
                                                              • API Reference
                                                              • Examples
                                                              • Marks

                                                                • Overview
                                                                • Writing Marks
                                                                • Using Marks
                                                                • Examples
                                                              • Dill

                                                                • Overview
                                                                • API Reference
                                                                • Scry Reference
                                                                • Data Types
                                                                • Eyre

                                                                  • Overview
                                                                  • External API Reference
                                                                  • Internal API Reference
                                                                  • Scry Reference
                                                                  • Data Types
                                                                  • Guide
                                                                  • Gall

                                                                    • Overview
                                                                    • API Reference
                                                                    • Data Types
                                                                    • Threads Reference
                                                                    • Iris

                                                                      • Overview
                                                                      • API Reference
                                                                      • Data Types
                                                                      • Example
                                                                      • Jael

                                                                        • Overview
                                                                        • API Reference
                                                                        • Scry Reference
                                                                        • Data Types
                                                                        • Examples
                                                                        • Threads

                                                                          • Overview
                                                                          • HTTP API
                                                                          • Reference
                                                                          • Gall

                                                                            • Start Thread
                                                                            • Take Result
                                                                            • Take Facts
                                                                            • Stop Thread
                                                                            • Poke Thread
                                                                            • Examples

                                                                              • Fetch JSON
                                                                              • Child Thread
                                                                              • Main-loop
                                                                              • Poke Agent
                                                                              • Scry
                                                                              • Take Fact
                                                                            • Concepts

                                                                              • Scries
                                                                              • Subscriptions
                                                                              • Tutorials

                                                                                • Move Trace
                                                                                • Reference

                                                                                  • Cryptography
                                                                                  • Filesystem Hierarchy
                                                                                • Nock

                                                                                  • Nock Definition
                                                                                  • Explanation
                                                                                  • Example
                                                                                  • Implementations
                                                                                  • Vere

                                                                                    • C Runtime System
                                                                                    • Land of Nouns
                                                                                    • API overview by prefix
                                                                                    • C in Urbit
                                                                                    • Writing Jets
                                                                                    • Cryptography
                                                                                    • Azimuth

                                                                                      • Overview
                                                                                      • Urbit HD Wallet
                                                                                      • Azimuth Data Flow
                                                                                      • Azimuth.eth
                                                                                      • Ecliptic.eth
                                                                                      • Advanced Azimuth Tools
                                                                                      • Life and Rift
                                                                                      • Layer 2

                                                                                        • Layer 2 Overview
                                                                                        • Layer 2 Actions
                                                                                        • Transaction Format
                                                                                        • Rollers
                                                                                        • Roller HTTP RPC-API
                                                                                        • Custom Roller Tutorial
                                                                                      • Glossary

                                                                                        • Ames
                                                                                        • Aqua
                                                                                        • Arm
                                                                                        • Arvo
                                                                                        • Atom
                                                                                        • Azimuth
                                                                                        • Battery
                                                                                        • Behn
                                                                                        • Bridge
                                                                                        • Censures
                                                                                        • chat
                                                                                        • Claims
                                                                                        • Clay
                                                                                        • Comet
                                                                                        • Core
                                                                                        • Delegated Sending
                                                                                        • Desk
                                                                                        • Dill
                                                                                        • Document Proposal
                                                                                        • Dojo
                                                                                        • Door
                                                                                        • Ecliptic
                                                                                        • Event Log
                                                                                        • Eyre
                                                                                        • Galaxy
                                                                                        • Gall
                                                                                        • Gate
                                                                                        • HD Wallet
                                                                                        • Hoon
                                                                                        • Invite Tree
                                                                                        • Iris
                                                                                        • Jael
                                                                                        • Keyfile
                                                                                        • Khan
                                                                                        • Landscape
                                                                                        • Mark
                                                                                        • Moon
                                                                                        • Nock
                                                                                        • Noun
                                                                                        • OTA Updates
                                                                                        • Payload
                                                                                        • pH
                                                                                        • Pier
                                                                                        • Pill
                                                                                        • Planet
                                                                                        • Proxies
                                                                                        • Replay
                                                                                        • Factory Reset
                                                                                        • Naive rollups
                                                                                        • Sail/Udon
                                                                                        • Senate
                                                                                        • Ship
                                                                                        • ship.arvo.network
                                                                                        • Star
                                                                                        • |sync
                                                                                        • Trap
                                                                                        • Upgrade Proposal
                                                                                        • Vane
                                                                                        • Vere
                                                                                        • Voting
                                                                                        • Wallet-Generator
                                                                                        • Additional

                                                                                          • Cryptography
                                                                                          • Software Distribution

                                                                                            • Overview
                                                                                            • Docket File
                                                                                            • Glob
                                                                                          Reference/Hoon/Runes

                                                                                          Nock . ('dot')

                                                                                          Anything Nock can do, Hoon can do also. These runes are used for carrying out Nock operations in Hoon.

                                                                                          .^ "dotket"

                                                                                          Load from the Arvo namespace (scry) with a fake Nock instruction: Nock 12.

                                                                                          Syntax

                                                                                          Two arguments, with the second optionally split into an arbitrary number of elements.

                                                                                          While this rune technically takes a fixed number of arguments, q is usually split into at least two parts, and the tall form of this rune must be terminated with a ==. Note also that the == does not make the arguments into a list as you might expect, so q must be explicitly null-terminated if its elements are specified separately.

                                                                                          FormSyntax
                                                                                          Tall
                                                                                          .^ p
                                                                                          q1
                                                                                          q2
                                                                                          q3
                                                                                          qn
                                                                                          ==
                                                                                          Wide
                                                                                          .^(p q1 q2)
                                                                                          IrregularNone.

                                                                                          AST

                                                                                          [%dtkt p=spec q=hoon]

                                                                                          Produces

                                                                                          The noun q, cast to the type p.

                                                                                          Discussion

                                                                                          Nock has no 12 instruction! But the virtual Nock used to run userspace code does. Nock 12 loads from a typed immutable namespace defined by its virtual context.

                                                                                          Ordinarily a Hoon expression has access to no information but whatever can be found in the subject. The one exception is with the .^ rune. It essentially allows you to request information from one of the Arvo vanes (modules).

                                                                                          .^ checks that the type of the value retrieved from Arvo nests under p. q is a path which includes information about which vane is being queried, and what sort of information is requested.

                                                                                          In principle .^ takes two subexpressions, but in practice q is often given in two parts: the first part includes the vane to be queried (e.g., %a for Ames, %b for Behn, %c for Clay, etc.) and the kind of request. The second part is a path that corresponds to the kind of request.

                                                                                          Examples

                                                                                          In the dojo we can ask Clay -- the Arvo filesystem -- for a listing of the files at our current path, %:

                                                                                          > .^(arch %cy %)
                                                                                          [ fil=~
                                                                                          dir
                                                                                          { [p=~.app q=~]
                                                                                          [p=~.sur q=~]
                                                                                          [p=~.gen q=~]
                                                                                          [p=~.lib q=~]
                                                                                          [p=~.mar q=~]
                                                                                          [p=~.ted q=~]
                                                                                          [p=~.desk q=~]
                                                                                          [p=~.sys q=~]
                                                                                          }
                                                                                          ]

                                                                                          The %c is for Clay, and the y is for the request type. arch is the type of the listing. See gen/cat.hoon to see how this information is printed more prettily.

                                                                                          The % is for the current path in the dojo:

                                                                                          > `path`%
                                                                                          /~zod/base/~2018.9.20..23.05.35..0231

                                                                                          You can modify the time of the file listing quite simply and ask for a listing from 5 hours ago. (Remember that Clay is a revision-controlled file system.)

                                                                                          > .^(arch %cy /(scot %p our)/base/(scot %da (sub now ~h5)))
                                                                                          [ fil=~
                                                                                          dir
                                                                                          { [p=~.app q=~]
                                                                                          [p=~.sur q=~]
                                                                                          [p=~.gen q=~]
                                                                                          [p=~.lib q=~]
                                                                                          [p=~.mar q=~]
                                                                                          [p=~.ted q=~]
                                                                                          [p=~.desk q=~]
                                                                                          [p=~.sys q=~]
                                                                                          }
                                                                                          ]

                                                                                          our is the value for your ship's name.


                                                                                          .+ "dotlus"

                                                                                          Increment an atom with Nock 4.

                                                                                          Syntax

                                                                                          One argument, fixed.

                                                                                          FormSyntax
                                                                                          Tall
                                                                                          .+ p
                                                                                          Wide
                                                                                          .+(p)
                                                                                          Irregular
                                                                                          +(p)

                                                                                          AST

                                                                                          [%dtls p=hoon]

                                                                                          Produces

                                                                                          p plus 1 if p is an atom; otherwise, crashes. The product atom has no aura.

                                                                                          Examples

                                                                                          > .+(6)
                                                                                          7
                                                                                          > +(6)
                                                                                          7
                                                                                          > +(%foo)
                                                                                          7.303.015
                                                                                          > +([1 2])
                                                                                          nest-fail

                                                                                          .* "dottar"

                                                                                          Evaluate with Nock 2.

                                                                                          Produces

                                                                                          Nock of formula q and subject p, with type %noun.

                                                                                          Syntax

                                                                                          Two arguments, fixed.

                                                                                          FormSyntax
                                                                                          Tall
                                                                                          .* p
                                                                                          q
                                                                                          Wide
                                                                                          .*(p q)
                                                                                          IrregularNone.

                                                                                          AST

                                                                                          [%dttr p=hoon q=hoon]

                                                                                          Discussion

                                                                                          .*(p q) is used to run Nock formula q on the subject p from within Hoon.

                                                                                          Keep in mind that p and q can be arbitrary Hoon expressions, as long as they evaluate to the appropriate nouns for Nock evaluation.

                                                                                          Note also that .* ("dottar") can be used to bypass the type system. It's therefore possible to use Hoon as a typeless language.

                                                                                          Examples

                                                                                          > .*([20 30] [0 2])
                                                                                          20
                                                                                          > .*(33 [4 0 1])
                                                                                          34
                                                                                          > .*(|.(50) [9 2 0 1])
                                                                                          50
                                                                                          > .*(12 [7 [`1 [4 `1]] [`2 `3 `2]])
                                                                                          [12 13 12]
                                                                                          > .*(~ [5 1^4 [4 1^3]])
                                                                                          0
                                                                                          > .*(~ [5 1^5 [4 1^3]])
                                                                                          1

                                                                                          .= "dottis"

                                                                                          Test for equality with Nock 5.

                                                                                          Syntax

                                                                                          Two arguments, fixed.

                                                                                          FormSyntax
                                                                                          Tall
                                                                                          .= p
                                                                                          q
                                                                                          Wide
                                                                                          .=(p q)
                                                                                          Irregular
                                                                                          =(p q)

                                                                                          AST

                                                                                          [%dtts p=hoon q=hoon]

                                                                                          Produces

                                                                                          %.y if p equals q; otherwise %.n.

                                                                                          Discussion

                                                                                          Like Nock equality, .= ("dottis") tests whether two nouns are the same, ignoring invisible pointer structure. Because in a conventional noun implementation each noun has a lazy short hash, comparisons are fast unless the hash needs to be computed, or we are comparing separate copies of identical nouns. (Comparing large duplicates is a common cause of performance bugs.)

                                                                                          Examples

                                                                                          > .=(0 0)
                                                                                          %.y
                                                                                          > =(0 0)
                                                                                          %.y
                                                                                          > .=(1 2)
                                                                                          %.n
                                                                                          > =(1 2)
                                                                                          %.n
                                                                                          > =(12 [12 14])
                                                                                          %.n

                                                                                          .? "dotwut"

                                                                                          Test for cell or atom with Nock 3.

                                                                                          Syntax

                                                                                          One argument, fixed.

                                                                                          FormSyntax
                                                                                          Tall
                                                                                          .? p
                                                                                          Wide
                                                                                          .?(p)
                                                                                          IrregularNone.

                                                                                          AST

                                                                                          [%dtwt p=hoon]

                                                                                          Produces

                                                                                          %.y if p is a cell; otherwise %.n.

                                                                                          Examples

                                                                                          > .?(42)
                                                                                          %.n
                                                                                          > .?([42 43])
                                                                                          %.y

                                                                                          <-

                                                                                          Atoms and strings

                                                                                          Wild ! ('zap')

                                                                                          ->

                                                                                          Edit this page on GitHub