-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ER: add abs/0; deprecate or discourage NUMBER | length
#2672
Comments
Well, we do have |
@nicowilliams wrote:
because: (a) using jqMaster, that would ensure that
b) in some ways, it "future proofs" jq by pushing the semantics upstream. In any case, if Of course, if |
See #2676 Note that this PR defines |
Included by #2767. |
Most programming languages have an
abs
or similarly named function for convenient computation of the absolute value of a number. In its stead, jq haslength
, whichfor 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
forabsolute value
, and even if that's not the case,abs
more clearly indicates intention.The text was updated successfully, but these errors were encountered: