Data type selectors inform an engine and viewer how to interpret values so that they can be optimized for storage and display. Types are not required and do not need to be declared in advance. Any data types which are not understood by the viewer are simply ignored in rendering the screen and do not change the appearance of atom's value. Any data types which are not understood by the engine are stored with the atom and ignored.
Data types can flexibly represent real information that might be found in narrative text without inducing breakage from unusual values, such as the very large and small numbers found in scientific notation. Data types can be used to denote inline code which is useful in creating viewers for code editing or programming language development. Data types can also indicate binary results, such as a link to a YouTube video in narrative text that could be played directly in the viewer.
Data types serve as a way to select the desired meaning from an atom or its metadata and so they are the third type of selector. Like other selectors, data types are preserved when an atom is used again later, so they only need to be set once. Data types can also be set in canon. Data types are different from formats because they denote how a value should be interpreted rather than how it should appear in the viewer.
(@10M 10000000 (d number)) ⇒ 10000000 (@10M 10,000,000 (d number)) ⇒ 10000000 (@10M 10.000.000 (d number)) ⇒ 10000000 (@10M 10M (d number)) ⇒ 10000000 (@10M 10 million (d number)) ⇒ 10000000 (@10M 1.0E7 (d number)) ⇒ 10000000 (@ONE-THIRD 10/3) ⇒ 10/3 (@ONE-THIRD (d number integer)) ⇒ 3 (@ONE-THIRD (d number real 3)) ⇒ 0.333
Data types can be combined with formats to change how values are shown are the screen without changing their representation in narrative text. This allows factual values such as "$5M" to be captured in narrative text and used as numbers in comparisons, conversions, or other operations.
(@FIVE-M 5M (d number)) ⇒ 5000000 (@FIVE-M (d number real 2) (f currency)) ⇒ $5,000,000.00 (@FIVE-M (f currency convert php)) ⇒ ₱ 253,284,500 (@FIFTY-M fifty million dollars (d number integer) (f currency)) ⇒ $50,000,000 (@FIFTY-M 53.5 million Bahamian dollars (d number integer) (f currency bsd)) ⇒ B$50,000,000
These data types might be used in a narrative expression as such:
(@p1 By (@1995), the resort developer had invested over (@cost PHP 253284500 (d number) (f currency php)) or about (@cost (d number integer) (f currency convert usd) US dollars in the project.)
By 1995, the resort developer had invested over ₱ 253,284,500 or about $50 million US dollars in the project.
Later writing which referred to
(@cost) could use a different format to view the original number in a new way, such as adjusted for inflation.
(@p2 This represented a significant commitment to local economy of the time, equivalent to more than (@cost (d number integer 2) (f currency convert usd words) (f currency inflate 1995 2019)) today.
This represented a significant commitment to the local economy of the time, equivalent to more than $83 million today.
All data types are essentially custom and can be defined and used in any way that suits your application.
This wiki presents suggested data types that can be used when building engines and viewers. None of these types is required to implement a viewer or engine, but a basic viewer or engine should be able to cope with these recommended types.
It is anticipated that many more data types will be developed for specialized text and applications, such as 3D models, chemical and mathematical formulas, complex series, and so forth. Data type expressions use the same key selector value syntax as other MSL expressions which allows unlimited types and parameters for types (their metadata).
Custom types can be used to designate any other type of data which is not represented in these recommendations, or to provide alternative syntax for a type. Custom types should be used only where they provide beneficial information to the engine in storing the data or to the viewer in interpreting it for display. Data-about-data which can be represented as text should be stored as metadata rather than using custom types.
(@script Ibuprofen :amt 500 mg :freq tid (d rx)) (@rocket-sensor-values [wss://stream-source] (d bitstream)) (@arithmetic-math πr^2 (d math)) (@msds-library [filespec] (d msds multiple))