@enumeratio/engine
Plumbing over @cortex-js/compute-engine: checked accessors for reading values out of BoxedExpression, Wolfram-style options and messages, a cooperative deadline, one seeded Random, and the Power LaTeX entry every dictionary needs. Every symbol package sits on top of this one — it has no workspace dependencies of its own.
.(src/index.ts) —operandsOf,symbolNameOf,integerAt,bigIntegerAt,stringAt: read.ops/.symbol/.re/.numericValueoff aBoxedExpressionthrough one checked accessor apiece rather than casting the union at every call site.src/apply-function.ts—applyFunction(ce, f, args): the one way a head calls a user function. AFunctionliteral binds its arguments whole (Wolfram's semantics, slot-only bodies included), where compute-engine's own call maps an untyped lambda over a list argument.src/options.ts— Wolfram-style trailing option rules (PlotRange -> (-1, 1)):OptionsPatternsemantics, leftmost setting wins, read and written without rewriting the expression to hold them.src/messages.ts—Head::codemessages: a head that declines to evaluate stays unevaluated (never["Error", …]) but can say why, with arguments spliced into a template. See also Syntax and Formats.src/deadline.ts—withDeadline/checkpoint(): a cooperative budget for loops (Pollard rho, baby-step giant-step) that never pass through compute-engine's own boxed deadline frame.src/random.ts— the oneRandomhead, drawing from a seeded stream per engine (Random); Wolfram'sRandomInteger/RandomVariaterewrite to it.src/latex.ts— theLatexRulehook: a library declares how a head reads and writes LaTeX as aLatexDictionaryEntrynarrowed to the parser and serializer methods libraries call (LatexReader,LatexWriter);latexEntriesis where it becomes compute-engine's own.src/inputform.ts—toInputForm: an expression printed as Epsil you could retype, over compute-engine'sserializeEpsil. Here soToStringneeds no format registry;@enumeratio/formats/inputformre-exports it.src/facade.ts— what a library imports in place of@cortex-js/compute-engine:Engine,Expr,Json,HeadDefinition,EvalOptions,Type(aliases of compute-engine's own types), theisNumber/isSymbolguards,box(ce, json), and the patterns libraries used to reach into compute-engine for (src/probe.ts):isNativeHead(is it already defined?),nativeEvaluate/nativeCanonical(the current handler, to fall back on) andwithAssumptions(assume inside a scope that is dropped after). Theno-restricted-importsrule in the rootvite.config.tskeeps libraries (packages/symbols) to it; files still importing compute-engine are inpackages/utils/tests/compute-engine-imports.baseline.json, which may only shrink../testing(src/testing.ts) —createEngine(...declares): a fresh engine with the givendeclareXsteps applied in order;bareEngine(): one with nothing declared;createLatexEngine(rules, ...declares): one whose LaTeX dictionary has theLatexRules../unstable(src/unstable.ts) — the full compute-engine API, outside semver. Each use carries an// unstable: <reason>comment../unstable/latex-syntaxis the same for compute-engine's/latex-syntax../compiled(src/compiled.ts) — a separate entry so only packages that actually compile to JavaScript pull in compute-engine's compiler.compileExpressionlowers an expression to a function of its free variables; a head's own lowering is its definition'scompilefield (CompileHandler).
Commands
sh
vp check # format, lint, type check
vp test # tests/*.test.ts
vp pack # build dist (also: vp pack --watch)Next
Reference entries and oracle goldens for heads that use this plumbing live in reference. For the Head::code message convention and Epsil generally, see Syntax and Formats.
- Source:
packages/engine - In development, also:
config