Leedehai/typst-physics

`pdv` with single argument

ParadaCarleton opened this issue · 1 comments

Hi! Thank you for this amazing package, it's a huge help to the whole Typst community :)

I wanted to ask, should there be a single-argument form of pdv? Intuitively I'd expect pdv(x) to give diff / (diff x).

Hi, thanks for your feedback!

When I was implementing the function I thought about the single-argument form, but decided to not add it because it could create confusion: if pdv(x) displays diff / (diff x), then what should pdv(x, t) be: (diff x) / (diff t) or diff / (diff x diff t)?

Unlike Latex, Typst doesn't provide a special syntax for optional args like func[optional]{args} so we could write pdv{x} and pdv[f]{x} to differentiate diff / (diff x) and (diff f) / (diff x). Certainly, we could adopt a special rule along the line of "if there's only one argument, treat it as the variable name and leave the function name empty; if there are multiple arguments, treat the first as the function name and the rest as variable names", but I'd prefer not to carve out an ad-hoc special rule. Also (though a minor point), one could say, "I'd rather adopt the special rule that treats the single argument as the function name, and the variable name shall be x by default, because this is quite common".

That said, I do recognize the necessity to write the operator form (i.e. without a function name), so you may simply omit the function name (as shown in the manual pdf), which is more explicit in the intention:
Screenshot 2023-05-02 at 11 18 18