Ordered inputs
A v4 tree value file whose function takes four parameters in the order rate, amount, discount, limit: G, F,
G, F. Its output has type F and its body returns the input amount. The order of inputTypes is the parameter
order, so the written file keeps it. Every other object is sorted as JCS sorts it.
The written form of the plain document. def (inside it ExpressionBody before access; inside that body,
inputTypes, outputType), then formatVersion, then name. inputTypes keeps rate, amount, discount,
limit. Plain JCS would write amount, discount, limit, rate, which would change the function.
Occurrences in first-use order, by offset in that written form:
amount(names) atbody/Variable, O = 8, once. Tentative ida: S = 8 − 13 = −5; E = 1 + 6 + 6 = 13. −5 ≤ 13: spelled out, andais not consumed. The keyamountofinputTypesis a map key, not a position.- G (
fqNames) atinputTypes/rateandinputTypes/discount, each O = 88. Ida: S = 2 × (88 − 13) = 150 > E = 1 + 86 + 6 = 93: aliased asa. - F (
fqNames) atinputTypes/amount,inputTypes/limitandoutputType, each O = 101. Idb: S = 3 × (101 − 13) = 264 > E = 1 + 99 + 6 = 106: aliased asb. adjust(names) atname, O = 8, once. Tentative idc: S = −5 ≤ E = 13: spelled out.
G's first use is inputTypes/rate, before F's at inputTypes/amount, so G takes a. Over plain JCS order, F would
come first at inputTypes/amount and take a.
Plain size. {"def":{"ExpressionBody":{"body":{"Variable":"amount"},"inputTypes":{ is 69 bytes. The four
members are "rate": (7) + 88 = 95, "amount": (9) + 101 = 110, "discount": (11) + 88 = 99 and "limit": (8) +
101 = 109, with 3 commas: 416. Then } (1), ,"outputType": (14), F (101), } (1), ,"access":"Public" (18), }
(1), ,"formatVersion":4 (18), ,"name":"adjust" (16) and } (1). 69 + 416 + 171 = 656 bytes.
Loss decision. Overhead = 118 + 12 + (1 + 86 + 5) + (1 + 99 + 5) + 1 = 328. Savings 150 + 264 = 414 > 328, so the envelope is written, 86 bytes smaller: 656 bytes plain, 656 − 414 + 328 = 570 bytes compacted.