Calcish JavaScript runtime is based on QuickJS, which implements the ECMAScript 2020 specification.
Due to the synchronous nature of Calcish, while the language is fully compatible, there are a few differences with other runtimes, such as browsers and Node.js:
setTimeout, setInterval).Language features can be changed in Codebook settings for a particular codebook, or globally in Settings ▸ Language.
In Math mode:
Floating-point numbers are BigFloat by default.
Integers that can’t be represented by Number are BigInt by default.
The power operator ** can be used with unparenthesized unary expressions (for example, -2**2).
The modulo operator % returns the Euclidian remainder (always positive) instead of the truncated remainder
(in Math mode, -13 % 5 = 2, while in normal mode -13 % 5 = -3).
Note that functions in the Math object that work with number type are not modified for compatibility
reasons: instead, use the top-level functions, such as sin, which work with any number type,
including BigFloat, or the corresponding methods, such as BigFloat.prototype.sin.
In Math mode, when the Fractions option is on, integer division returns Fraction objects,
for example 1/2 is Fraction(1, 2), represented as $\frac{1}{2}$.
When the Vectors & Matrices option is on, arrays can be treated as vectors, and arrays of arrays can be treated as matrices.
Operators on arrays work as if they were vectors and matrices:
[1, 2] + [3, 4] returns [4, 6],[[1, 2], [3, 4]] * 2 returns [[2, 4], [6, 8]].Operators can be defined in object’s prototype Symbol.operatorSet property.
They are created using Operators.create.
For example, here’s how new Color('yellow') + new Color('cyan') works:
Color.prototype[Symbol.operatorSet] = Operators.create({
"+": (left, right) => Color.mix(left, right)
})