Built-in realizations and context wrappers, as data.
A realization renders one intent in one language. It declares every capability its text relies on, and the solver admits it only when the profile holds evidence that each one is :yes.
A wrapper is a context emitter: it turns a program in an inner language into a program in an outer one (sh running python3 -c, python running sh -c, ...). Wrappers build context stacks, both for automatic delegation and for an explicitly requested stack.
:render receives an env whose (:lit env) is (fn [lang s] candidates) and returns a lazy seq of candidates (see grammar.candidate), ascending by :cost: best-first takes the first one's cost as a lower bound for the rest. grammar.candidate/leaf and grammar.candidate/combine both return such seqs. A realization's :cost and a wrapper's :cost are numbers >= 0 and every :id is a keyword; grammar.solve/make-env refuses anything else.
Length law: no output is shorter, in UTF-8 bytes, than the text an encoder encodes or than any piece a realization or wrapper embeds. The solver relies on it to drop a candidate already over the profile's :max-len together with everything that would be built from it. It is grammar.law/length-law-violations, checked over this registry by grammar.length-law-test; an entry that breaks it declares :shortens?.
Built-in realizations and context wrappers, as data. A realization renders one intent in one language. It declares every capability its text relies on, and the solver admits it only when the profile holds evidence that each one is :yes. A wrapper is a context emitter: it turns a program in an inner language into a program in an outer one (sh running python3 -c, python running sh -c, ...). Wrappers build context stacks, both for automatic delegation and for an explicitly requested stack. :render receives an env whose (:lit env) is (fn [lang s] candidates) and returns a lazy seq of candidates (see grammar.candidate), ascending by :cost: best-first takes the first one's cost as a lower bound for the rest. grammar.candidate/leaf and grammar.candidate/combine both return such seqs. A realization's :cost and a wrapper's :cost are numbers >= 0 and every :id is a keyword; grammar.solve/make-env refuses anything else. Length law: no output is shorter, in UTF-8 bytes, than the text an encoder encodes or than any piece a realization or wrapper embeds. The solver relies on it to drop a candidate already over the profile's :max-len together with everything that would be built from it. It is grammar.law/length-law-violations, checked over this registry by grammar.length-law-test; an entry that breaks it declares :shortens?.
(bin-cap program)Capability: exec finds program as an executable file on PATH (what python's subprocess needs).
Capability: exec finds program as an executable file on PATH (what python's subprocess needs).
(cmd-cap program)Capability: the shell resolves program as a command word, builtins and applets included (what an sh simple command needs).
Capability: the shell resolves program as a command word, builtins and applets included (what an sh simple command needs).
(py-bytes e)python expression for the UTF-8 bytes of python str expression e. An argv word handed to subprocess as bytes is never encoded with the locale, so a non-ASCII word survives LC_ALL=C with PYTHONUTF8=0. str.encode() with no argument is UTF-8 whatever the locale, and adds no quote character, so a policy forbidding quotes still admits it.
python expression for the UTF-8 bytes of python str expression e. An argv word handed to subprocess as bytes is never encoded with the locale, so a non-ASCII word survives LC_ALL=C with PYTHONUTF8=0. str.encode() with no argument is UTF-8 whatever the locale, and adds no quote character, so a policy forbidding quotes still admits it.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |