-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Most programming languages have an abs
or similarly named function for convenient computation of the absolute value of a number. In its stead, jq has length
, which
for many people is at best surprising. It is also noteworthy that this oddity was
not documented in jq 1.6 documentation until a recent commit (dd5ce98 on 2023-06-21).
Since NUMBER | length
has been around for a while, and since it has been documented,
I am not proposing that it be done away with, only that the recent above-mentioned update be further updated by deprecating or discouraging it. As @nicowilliams wrote: "Too much polymorphism in a dynamically typed language is a mistake."
In the context of jq, this is surely the pre-eminent example. AFAIK no other programming language uses the word length
for absolute value
, and even if that's not the case, abs
more clearly indicates intention.