( ce: ComputeEngine, name: MathJsonSymbol, semiOps: ReadonlyArray<ExpressionInput>, metadata?: Metadata, scope?: Scope )
| 874 | // unbound (see `BoxFunctionOptions.unboundSymbols`). |
| 875 | if ( |
| 876 | structural && |
| 877 | options.unboundSymbols !== true && |
| 878 | isStructuralBinder(ce, name, options.scope) |
| 879 | ) |
| 880 | options.unboundSymbols = true; |
| 881 | // The names it binds hide a macro in its operands (`macroAt()`). |
| 882 | if (structural && anyMacroDeclared(ce) && hidesNames(ce, name, options.scope)) |
| 883 | options.hidden = { head: name, ops, parent: options.hidden }; |
| 884 | |
| 885 | // Deep tree: box what is left of it with an explicit work stack instead of |
| 886 | // recursing into it (see `preboxDeepOperands`). The operands come back |
| 887 | // already boxed, so the construction below proceeds exactly as it would for |
| 888 | // a caller that had handed over boxed operands, and the recursion stops |
| 889 | // growing here. |
| 890 | if (boxingDepth >= boxingDevolveThreshold) { |
| 891 | const preboxed = preboxDeepOperands(ce, name, ops, options); |
| 892 | if (preboxed !== null) ops = preboxed; |
| 893 | } |
| 894 | |
| 895 | // An operand that IS, or that transitively CONTAINS, an object from another |
| 896 | // engine cannot be adopted into this engine's expression (see the same check |
| 897 | // in `boxInternal`). In a session that has never constructed an object this |
| 898 | // is a single boolean read for the whole operand list; only once an object |
| 899 | // exists anywhere does the per-operand walk run. |
| 900 | if (adoptsForeignEngineObject(ops, ce)) |
| 901 | return ce.error('object-foreign-engine'); |
| 902 | |
| 903 | // |
| 904 | // Hold |
| 905 | // |
| 906 | |
| 907 | if (name === 'Hold') { |
| 908 | // `Hold` takes one operand. Each extra operand is reported as an |
| 909 | // `unexpected-argument` error, as for any other operator (`Sin(1, 2)` is |
| 910 | // `Sin(1, Error('unexpected-argument', '2'))`). They were dropped with no |
| 911 | // error, so `Hold(x, 1)` was the valid `Hold(x)`. The node is built as |
| 912 | // canonical, so no signature check runs after this one. The operands |
| 913 | // are not flattened (`checkArity()` would flatten a `Sequence`): a held |
| 914 | // operand is kept as written. An operand that is already this error |
| 915 | // (the node is boxed again from its boxed operands) is kept as it is. |
| 916 | const held = [boxHold(ce, ops[0] ?? null, options)]; |
| 917 | for (const op of ops.slice(1)) { |
| 918 | const extra = boxHold(ce, op, options); |
| 919 | held.push( |
| 920 | isFunction(extra, 'Error') && |
| 921 | isString(extra.op1) && |
| 922 | extra.op1.string === 'unexpected-argument' |
| 923 | ? extra |
| 924 | : ce.error('unexpected-argument', extra.toString()) |
| 925 | ); |
| 926 | } |
| 927 | return new BoxedFunction(ce, 'Hold', held, { |
| 928 | ...options, |
| 929 | canonical: true, |
| 930 | structural, |
| 931 | }); |
| 932 | } |
| 933 |
no test coverage detected