Numlex Documentation

Custom units & constants

Define your own units and app-wide constants: grammar, dependencies, limits and rejection rules.

Main branch reference after R89 · released versions may differ docs/SYNTAX_REFERENCE.md @ 1ebc752

Two settings let you extend what a sheet can say: Settings → Units defines new units from existing ones (or as independent new atoms), and Settings → Constants defines up to 100 named values that every sheet can use.

This page documents both systems: naming rules, definition expressions, dependency resolution and cycles, the app-global scope (neither is written into .nlx exports), and the exact values each system accepts or rejects.

Custom units (Settings → Units)

Naming

  • 1–6 ASCII words, at most 40 characters; the first word starts with a letter.
  • The name must be unique: a collision with the catalog or with another custom unit is rejected.
  • The plural form of the name is accepted automatically, just like catalog atoms.

Definitions

Two kinds of definition are accepted:

  • <number> <existing unit expression> — for example 2.54 cm — which defines the new unit in terms of existing ones;
  • the literal new unit, which declares a new independent atom.

Dependencies and limits

  • Dependencies resolve in declaration order and outside it — the resolver is not order-sensitive.
  • A cycle is an error.
  • The global limit is 100 custom units.
  • Custom units are app-global (application settings) and are not saved in a .nlx sheet.
  • In a sheet, custom units behave like catalog units: quantities, conversion and arithmetic all work as documented in Units & quantities.

Constants (Settings → Constants)

Naming

  • 1–6 ASCII words, at most 40 characters; the first word starts with a letter.
  • Reserved categories exist: system names and categories cannot be overridden.

Expressions

  • The expression is stored verbatim as source text, at most 256 characters.
  • The result must be a final dimensionless scalar number, a percent, or a money quantity with a single fiat code.
  • A constant may reference other constants.

Dependencies and limits

  • Dependencies are independent of declaration order: values are recomputed by a pure ConstantResolver on every evaluation pass, because an edit in Settings instantly updates every sheet.
  • A cyclic dependency is an error.
  • The limit is 100 constants.
  • Constants are app-global and are not saved in .nlx.
  • Inside a sheet, constants are immutable — they can only be edited in Settings.

Verified examples

With PI, Tax and Rent declared in Settings → Constants:

PI × 2              → 6.283185307179586
Tax × 100           → 8           (Tax = 8% = 0.08; in multiplication the
                                   percent scalar returns as an ordinary number)
Rent × 12           → 14400 USD   (Rent = 1200 USD)

Rejected values

A constant line that resolves to any of these stays inactive:

  • a value with units (9.81 m/s²),
  • booleans,
  • dates,
  • assignments,
  • answer-token markers,
  • mixed currencies,
  • unknown names,
  • cycles.

Sheet names versus constants

Named values on a sheet are a separate mechanism from Settings constants (see Sheet language). An integer named value works on the integer lane:

x = 0x1F
x & 1               → 1
x as hex            → 0x1F

and x is not modified by the line x + 1.

Found an issue in these docs? Report it on GitHub .