Moving calc functions to methods where possible #4032
Labels
scripting
About Typst's coding capabilities
tracking-issue
An issue that tracks a larger piece of work.
This issue intends to track the progress of migrating
calc
functions to methods inint
andfloat
, as well as other types.The main reasons behind this effort are to improve organization of those functions - e.g.
calc.binom
is specific to ints, so it would make sense to invoke it asint.binom
instead, much like other operations we have today likesign
and bitwise operations -, but also to allow for new, more concise - but optional - syntax (e.g.5.rem(40)
is equivalent toint.rem(5, 40)
).PR #3489 started this effort, in a very general way, attempting to migrate all calc functions to methods.
After several rounds of discussion over Discord, it currently seems wiser to avoid doing that for the moment. In an initial phase, we should consider just migrating methods which unambiguously belong to either
int
orfloat
, such asint.binom
orfloat.sin
. Later on, we could decide how to deal with methods which work with a diversity of types (namelymin
,max
andabs
) as well as methods which have differing behavior for ints and floats (such aspow
). They could stay incalc
as needed, or in more than one place at once; that'd require further discussion.The text was updated successfully, but these errors were encountered: