! zap · Wild
!, "zapcom"
Produce the Hoon AST of an expression.
Syntax
Two arguments, fixed.
!, p
q!,(p q)None
AST
[%zpcm p=hoon q=hoon]Discussion
This produces the $hoon AST of expression .q. The first argument, .p, is always an example of the $hoon type, typically just the *hoon bunt value, and is used for type inference. The reason for .p is just to handle transitions if the $hoon type changes.
Examples
> !, *hoon [1 1]
[%cltr p=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]
> !, *hoon (add 1 1)
[%cncl p=[%wing p=~[%add]] q=~[[%sand p=%ud q=1] [%sand p=%ud q=1]]]!> "zapgar"
Wrap a noun in its type (form a $vase).
Syntax
One argument, fixed.
!> p
!>(p)
None
AST
Produces
A cell whose tail is the product of .p, and whose head is the static type of .p.
Discussion
In Hoon, a dynamic type is a static type compiled at runtime. This type-noun cell is generally called a $vase.
Examples
If you want just the type value, use a 'type spear'. This is -:!>, i.e., the head of the cell produced by !>:
!< "zapgal"
Extracts a $vase to the given mold if its type nests.
Syntax
Two arguments, fixed.
None
AST
Produces
The value of vase .q typed with the type of mold .p if possible, else a nest-fail.
Discussion
This is something like a partial inverse to the !> rune and can be used to extract a typed value from a $vase.
Examples
!; "zapmic"
Wrap a noun in its type (raw).
Syntax
Two arguments, fixed.
None
AST
Discussion
This wraps the product of .q in its inferred type. It's a raw version of !>. Unlike zapgar, .q is not given a face p and its type information is not stripped to a raw noun.
The first field, .p, must be an example of the $type type, typically just *type (the bunt of $type). The .p argument is just so transitions can be handled if the $type type changes.
It's unlikely you'd use this rune directly; !> is much more typical.
Examples
!= "zaptis"
Make the Nock formula for a Hoon expression.
Syntax
One argument, fixed.
None
AST
Produces
The Nock generated by .p.
Discussion
Don't confuse != with a negation, !, followed by a test for equality, =(10 11).
Examples
Don't confuse the != rune with:
The syntax difference is that a test for equality takes two subexpressions, and the != rune only one.
!? "zapwut"
Restrict Hoon version.
Syntax
Two arguments, fixed.
None
AST
Produces
When .p is an atom:
.qif.p≥ Hoon kelvin version, otherwise crash.
When .p is a cell:
.q, ifp.p≥ Hoon kelvin version ≥q.p, otherwise crash.
(Versions count down; the current version is 140.)
Examples
!@ "zappat"
Branch on whether a wing exists.
Syntax
Three arguments, fixed.
None
AST
Discussion
.p is a wing reference like foo, bar.foo, etc. If .p exists, .q. If .p does not exist, .r. Essentially, this is like ?: for wing existence.
Examples
!! "zapzap"
Crash.
Syntax
No arguments.
!!
!!
None
AST
Produces
Nothing. Always crashes, with type %void.
Discussion
%void nests in every other type, so you can stub out anything with !!.
Examples
!: "zapcol"
Turn on stack trace.
Syntax
One argument, fixed
!: p
!:(p)
None
Produces
The product of .p unless .p crashes, in which case a stack trace is given.
Discussion
!: is used to turn on a debugging stack trace option for any code you have in .p.
Examples
!. "zapdot"
Turn off stack trace for a subexpression .p
Syntax
One argument, fixed.
!. p
!.(p)
None
Produces
The product of .p. If .p crashes, no stack trace entries are given for that code.
Discussion
!. is used to turn off a debugging stack trace option for any code you have in .p. This rune can be embedded under a !: rune for inner loops of your code that you don't want or need to trace. This is especially useful if a trace overflows the stack.
Examples
Last updated