Toml: Add version type

Created on 17 Feb 2017  路  4Comments  路  Source: toml-lang/toml

Since TOML is widely used for specifying software configurations, it makes sense to add a _Version_ type to the spec.

Example:

[project]
version = v1.2.4

The v prefix differentiates the version from a floating-point number and emphasizes the type of the value.

Although it is optional, libraries can compare version types according to the Semantic Versioning policy.

Most helpful comment

The problem with the version type is that it doesn't map to a "native" type. It maps to a String, that's it. And since everyone has a different version format I don't see what kind of checking the parser could do.

Also, if TOML adds a Version type, then a URL type is also needed, and a filename type, and a currency type, etc.

All 4 comments

Why not just use a String ?

TOML already has first-class datetimes. I believe they have been added for clarity in configs and stronger type-checking in implementations. The same reasons go for the Version type.

Another useful addition might be the datetime _duration_, maybe something in the DNS zone file style: (1h or 3m).

The obvious downside of adding new types is the increased complexity of the spec and implementations. However, providing explicit typing for widely used, unambiguous and simple data types brings more structure into config files. The question is whether a particular data type is really that widely used, unambiguous and simple (Integer surely is, but Currency probably not because it's complex).

The problem with the version type is that it doesn't map to a "native" type. It maps to a String, that's it. And since everyone has a different version format I don't see what kind of checking the parser could do.

Also, if TOML adds a Version type, then a URL type is also needed, and a filename type, and a currency type, etc.

Yes, you are right, so this issue should be closed.
Also, version strings are actually _not_ simple: version requirements Rust's Cargo package manager is the example.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uvtc picture uvtc  路  3Comments

chillum picture chillum  路  4Comments

jdfergason picture jdfergason  路  4Comments

jakwings picture jakwings  路  3Comments

Suhoy95 picture Suhoy95  路  4Comments