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

Why "integer" instead of "int" in the primitive schemas? #173

Open
jbkoh opened this issue Aug 3, 2023 · 3 comments
Open

Why "integer" instead of "int" in the primitive schemas? #173

jbkoh opened this issue Aug 3, 2023 · 3 comments

Comments

@jbkoh
Copy link

jbkoh commented Aug 3, 2023

Hi there,

In my understanding of the context file, it seems DTDL adopts XSD vocabularies. However, the definition of "integer" is mismatched between the DTDL's documentation vs XSD's definition.

DTDL v3:

  • integer

a signed integral numeric value that is expressible in 4 bytes

XSD

[Definition:] int is ·derived· from long by setting the value of ·maxInclusive· to be 2147483647 and ·minInclusive· to be -2147483648. The ·base type· of int is long.

[Definition:] integer is ·derived· from decimal by fixing the value of ·fractionDigits· to be 0and disallowing the trailing decimal point. This results in the standard mathematical concept of the integer numbers. The ·value space· of integer is the infinite set {...,-2,-1,0,1,2,...}. The ·base type· of integer is decimal.

like the hierarchy below
image

Basically, xsd:integer is unbounded and xsd:int is the 32bits integer as in your definition

I know I'm a bit pedantic, but wonder if there can be a chance to deprecate integer and start using int for long term alignment with one of the common standards.

@jrdouceur
Copy link
Collaborator

I don't know the history or the specific considerations that went into DTDL's choices for primitive schema terms, but I can make a few observations. First, DTDL prefers full words such as "integer" and "boolean" over truncations like "int" and "bool", but this is a lexical preference that does not drive the definition of the terms. Second, although the DTDL schemas make reference to XSD for some definitional aspects, they also refer directly to other standards including IEEE 754, ISO 8601, and IETF RFC 3339. Third, "integer" is not the only schema for which DTDL and XSD are not in alignment:

  • "duration" -- XSD allows prefixing with a minus sign and does not allow any forms with the "W" designator.
  • "string" -- XSD explicitly disclaims how UCS characters are encoded, whereas DTDL specifies UTF-8.

Some current and upcoming applications of DTDL relate to other standards, such as AVRO and Protobuf. I expect that if there are any future changes to DTDL schema definitions, these will be driven mainly by interop issues rather than by lexical alignment with XSD or the nomenclature of any other standard.

@koppor
Copy link

koppor commented Nov 29, 2023

I miss the relation to related work.

Especially, currently, I miss the physical unit. A temperature of 40.0°C is different from 40.0°F - even though the double value is the same...


SenML encodes temparature like that:

[
  {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1}
]

Using QUDT, a measurement would be encoded as follows in JSON:

{
  "value": 40,
  "unit": "http://qudt.org/vocab/unit/Celsius",
  "quantityKind": "http://qudt.org/vocab/quantitykind/Temperature",
  "description": "Measurement of temperature"
}

Reads nice.


Historical note. A decade ago, "everyone" talked about IoT. See for instance https://www.postscapes.com/internet-of-things-protocols/. Most of the lings are dead now... Nevertheless, I think, should be no re-invention of the wheel.

@koppor
Copy link

koppor commented Nov 29, 2023

Another thing to consider is "Eclipse Vorto", which is a language for digital twins - governede by the Eclipse Foundation, where Microsoft is also involved: https://eclipse.dev/vorto/

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

No branches or pull requests

3 participants