urbit/pub/doc/hoon/runes/kt/ktsg.md

48 lines
914 B
Markdown
Raw Normal View History

2015-02-18 06:03:21 +03:00
[ketsig, `^~`, %ktsg](#ktsg)
============================
Compile statically
`^~` is a natural hoon that tries to execute `p` statically at compile
time; if this fails, `p` remains dynamic. `^~` is primarily useful for
optimization, when you know that a value is static, or is most likely
static, `^~` can simplify the compilation.
Produces
--------
Twig: `[%ktsg p=twig]`
Sample
------
`p` is a [twig]().
Tall form
---------
^~ a
Wide form
---------
^~(a)
Irregular form
--------------
None
Examples
--------
/~zod/try=> (make '|-(42)')
[%8 p=[%1 p=[1 42]] q=[%9 p=2 q=[%0 p=1]]]
/~zod/try=> (make '^~(|-(42))')
[%1 p=42]
Here we use [`++make`]() to examine the nock generated for a particular
computation. We start with a simple kicked trap, `|-` that just
generates the static value `42`. When we wrap our `|-` in a `^~` you can
see that our compilation is much simpler.