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

Issue 493 - First draft of data type description #495

Merged
merged 8 commits into from
Sep 27, 2018
Merged

Conversation

kstreeter
Copy link
Collaborator

This PR addresses #493 by defining the logical type model for XDM, and adding a new meta:xdmType attribute to the meta schema.

| --------- | --------------------------------------------------------- | ---------------- | ------------------ |
| string | unlimited | string | |
| number | ±2.23×10^308 to ±1.80×10^308 (IEEE 64-bit floating point) | number | |
| long | (-2^53 + 1) - (2^53 + 1) (54-bit signed integer\*) | integer | |
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this not be a true 64 bit long? It's only javascript that is constrained right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For interoperability with Javascript, we have to define it within the constraints of what Javascript environments can support, which is the 54-bit signed range.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we agreed in another thread to not do that - and instead leave it full 64bits, but consider that some implementations can't handle that...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lrosenthol, are you saying that we should just call the range as 64-bit, leave the note that that in practice its only 53-bit?

I feel like we should just acknowledge the limitation here. The JSON/Javascript ecosystem only really supports a 54-bit integer. We want to interop with JS, so we adopt the same.

| --------- | --------------------------------------------------------- | ---------------- | ------------------ |
| string | unlimited | string | |
| number | ±2.23×10^308 to ±1.80×10^308 (IEEE 64-bit floating point) | number | |
| long | (-2^53 + 1) - (2^53 + 1) (54-bit signed integer\*) | integer | |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we agreed in another thread to not do that - and instead leave it full 64bits, but consider that some implementations can't handle that...

| short | -2^15 - 2^15 (16-bit signed integer) | integer | |
| byte | -2^7 - 2^7 (8-bit signed integer) | integer | |
| boolean | { true, false } | boolean | |
| date | n/a | string | date |
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should put references to 3339 or 8601 on the various dates

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is fixed in the latest commit

| date | n/a | string | date |
| date-time | n/a | string | date-time |
| array | n/a | array | |
| object | n/a | object | |
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you really mean object here or is this the "map" that you want?

@kstreeter kstreeter added this to the 0.9.6 milestone Sep 24, 2018
@cdegroot-adobe
Copy link
Contributor

@lrosenthol @kstreeter - I vote for the max being Number.MAX_SAFE_INTEGER ((2^53)-1)

My thinking:

JSON-LD is built on JSON-Schema which is built on JavaScript. The latter has the 53-bit Number limit ((2^53)-1).

type is constrained to what JSON allows

xdmType further refines, but cannot limit the constraints of type

Thus to my mind our long needs to be limited to Number.MAX_SAFE_INTEGER.

We have to accept that baggage or else say XDM is a special case, which we will end up having to repeat in perpetuity. I know it sucks, but we need to hold to consistency.

If you need really big numbers, they need to be string encoded.

| --------- | --------------------------------------------------------- | ---------------- | ------------------ |
| string | unlimited | string | |
| number | ±2.23×10^308 to ±1.80×10^308 (IEEE 64-bit floating point) | number | |
| long | (-2^53 + 1) - (2^53 + 1) (54-bit signed integer\*) | integer | |
Copy link
Contributor

@cdegroot-adobe cdegroot-adobe Sep 25, 2018

Choose a reason for hiding this comment

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

@kstreeter That range seems wrong to me, should it not be:
-(2^53 - 1) to (2^53 - 1) (54-bit signed integer*)

Copy link
Collaborator Author

@kstreeter kstreeter Sep 27, 2018

Choose a reason for hiding this comment

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

There is an error here @cdegroot-adobe, although the range you suggested is not correct either. From RFC 8259 section 6:

Note that when such software is used, numbers that are integers and
are in the range [-(2**53)+1, (2**53)-1] are interoperable in the
sense that implementations will agree exactly on their numeric
values.

Fixed two small typos, no semantic changes.
@lrosenthol
Copy link
Collaborator

@cdegroot-adobe - we have previously agreed that while the original JSON design (and the name) was built around JavaScript, neither JSON-LD nor JSON-Schema is built on JavaScript or its limitations.

That said, provided that we can resolve the xdmType issue, then I am OK with putting this limitation on XDM's long and saying that if you need something larger you must use BigNum - but that means we finalize that piece of work at the same time.

Fix the range for JSON integers
@kstreeter
Copy link
Collaborator Author

Thanks @lrosenthol. I filed issue #519 to track the need for BigDecimal/BigInteger types in XDM.

@kstreeter kstreeter merged commit b0c0c6b into master Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants