Skip to content
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

manual.yml: clarify and expand section on identity #2731

Closed
wants to merge 5 commits into from

Conversation

pkoppstein
Copy link
Contributor

Mostly clarifications w.r.t. numbers.

The anomalous behavior of leading minus signs is documented, with an explicit notice that this will probably change.

Mostly clarifications w.r.t. numbers.

The anomalous behavior of leading minus signs is documented, with an explicit notice that this will probably change.
Clarify that the effect of a leading minus sign only applies to numbers in a jq program.
fix two examples
@pkoppstein pkoppstein changed the title manual.yml: clarify and expand section on identify manual.yml: clarify and expand section on identity Jul 19, 2023
@itchyny itchyny added the docs label Jul 19, 2023
docs/content/manual/manual.yml Outdated Show resolved Hide resolved
@nicowilliams
Copy link
Contributor

nicowilliams commented Jul 19, 2023

We must not commit to number representations. RFC 8259 blessed -or cursed, depending on your viewpoint- JSON implementors with a great deal of latitude on internal (no limits here, as the RFC does not even envision tools like jq) and external JSON number representation. There is nothing like a canonical number representation. Any representation we choose, even a -in some cases- literal-preserving scheme like our current one could be obnoxious to some users. There is no right answer here, therefore we may not commit to even our current scheme.

We must remain free to replace decNumber or even go back to just IEEE 754 doubles if we want. I'm not saying that we will, but that we should retain that freedom.

Moreover, we should not impose our number representation schemes on other implementations of the jq language. The implementors of those ought to at least get a say, and the easiest thing to do in that regard is to not even raise the issue.

Any documentation regarding how jq supports numbers at this time must be explicit on this point.

processing can sometimes make it appear as though it does.
In particular, the parsing of JSON numbers can alter their
representation and even their value. For example, although
jq will attempt to maintain the original decimal precision
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/will/may/

representation of the number.
Also, any arithmetic operation on a number that has not
already been converted to an IEEE754 double precision
representation will trigger a conversion to the IEEE754
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/will/may/

Also, any arithmetic operation on a number that has not
already been converted to an IEEE754 double precision
representation will trigger a conversion to the IEEE754
representation. Currently, though this will probably change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this:

Currently, though this may change in the future, negative literals in jq programs may be converted to IEEE 754 doubles, with consequent loss in precision.


jq will also try to maintain the original decimal precision of the provided
number literal. See below for examples.
Comparisons, however, are carried out using the untruncated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/are/may be/

@nicowilliams
Copy link
Contributor

BTW, thank you for this @pkoppstein -- clearly we slipped up a bit in the docs when we accepted the decNumber contribution. We really should be very careful about what we say about number representations!

@pkoppstein
Copy link
Contributor Author

@nicowilliams @emanuele6 - Thanks for all the corrections and suggestions.

Please note that I've restructured the text with the intent of clearly identifying that which is subject to change,
in a way which should also make it easy to keep the documentation up-to-date.

Please also note that with the revised version, "All checks have passed".

As regards other implementations of jq: I agree it would be great to have a mutually agreed-upon definition of "standard jq", and clearly langjq serves as a kind of reference for other implementations. But manual.yml has not been written with buy-in from the authors of other implementations, and indeed both gojq and especially jaq deliberately depart from several key aspects of jq.

Until there is some kind of agreement amongst the jq, gojq, and jaq authors/maintainers/communities
about what "standard jq" or "core jq" is, I think manual.yml for jq 1.7 should continue to focus on jqlang, being clear about
what is intended to be stable, what is currently undefined, and, in some instances, what is likely to change.

That would also be helpful to the authors of other implementations, not least in the writing of their own documentation.

@nicowilliams
Copy link
Contributor

Thank you! LGTM.

I think on rebase-and-merge the merge commit will go away, but I strongly recommend doing git pull --rebase instead of git merge.

@pkoppstein
Copy link
Contributor Author

@nicowilliams wrote:

I strongly recommend ...

Is this for future reference, or would you like me to do something regarding this particular PR?

(If you want me to do something for this particular PR, I'd be inclined to delete it, and this branch, and start afresh. My git skills outside of GitHub Desktop are at best negligible.)

@nicowilliams
Copy link
Contributor

@pkoppstein in the list of commits for this PR there's a merge commit. I don't know whether clicking the "Rebase and merge" button would make that merge commit go away, but I want it to. We should very much try to have "linear history" in jq, which means no merge commits. This gist might be useful to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants