Answer architecture round 1: exempt only a calc operand from the read-once refusal, run the name passes from one list, read every operand's leaves, show a name operand in a README example, and plan a path through a name as an operand
This commit is contained in:
@@ -677,16 +677,23 @@ the SQL example above.
|
||||
|
||||
`{calc(expr)}` evaluates `+ - * /`, parentheses and unary minus over number
|
||||
literals, sibling field names and [names](#names), each rendered then read as a number;
|
||||
a second argument rounds to that many decimals. A name is the operand `{k}` prints:
|
||||
`{/n as k}{k} x 2 = {calc(k * 2)}` doubles the pick it shows. A hyphen is always
|
||||
subtraction, so a hyphenated field or name can't be an operand.
|
||||
a second argument rounds to that many decimals. A hyphen is always subtraction, so a
|
||||
hyphenated field or name can't be an operand.
|
||||
|
||||
```json
|
||||
{ "format": "{net} x {qty} = {calc(net * qty, 2)}", "net": ["19.99", "5.00"], "qty": ["3", "7"] }
|
||||
```
|
||||
|
||||
Renders e.g. `19.99 x 3 = 59.97`. A result that rounds to zero prints unsigned — `0`,
|
||||
`0.00` — as `{float()}`'s does. An operand that can never be a number (`"abc"`,
|
||||
Renders e.g. `19.99 x 3 = 59.97`. A name is the operand `{lat}` prints, so the calc computes
|
||||
from the pick shown:
|
||||
|
||||
```json
|
||||
"{/misc.coordinate.lat as lat}{lat}° is {calc(lat * 60, 0)} arcminutes"
|
||||
```
|
||||
|
||||
Renders e.g. `5.338477° is 320 arcminutes`.
|
||||
|
||||
A result that rounds to zero prints unsigned — `0`, `0.00` — as `{float()}`'s does. An operand that can never be a number (`"abc"`,
|
||||
or a choice of such) is rejected at load, as is a division by a constant zero
|
||||
(`1/0`, or a fixed `"0"` field); an operand that sometimes is not a number yields
|
||||
`NaN`, and a division by one that is not constant `Inf` — both print rather than
|
||||
@@ -771,8 +778,9 @@ Refused at `New`, each error naming what to write instead:
|
||||
- a binding of anything but a reference;
|
||||
- a binding in a choice's item, which every other item would leave unbound;
|
||||
- a binding nothing reads, or a binding of a whole category read once whole where it is
|
||||
bound, which the bare reference spells: `{/word as w}{w}` is `{/word}`, while
|
||||
`{/n as k}{calc(k * 2)}` stands, since a calc operand is no reference;
|
||||
bound, which the bare reference spells: `{/word as w}{w}` is `{/word}`. A calc's
|
||||
operand cannot be a reference, so there the name is the one spelling:
|
||||
`{/n as k}{calc(k * 2)}` loads;
|
||||
- a path through a name that selects a row;
|
||||
- `{n}` beside `{n.w}` where `n`'s category renders `w` twice, as in `{w}-{w}`;
|
||||
- reads of a name in two draw groups, or inside a `repeat` nested where the name is bound,
|
||||
|
||||
Reference in New Issue
Block a user