Re: [community-group] Remove units from type definitions (#121)

I want to drop a little “it depends” to this conversation, but more for consideration in future issues.

Given the current [character restrictions](https://design-tokens.github.io/community-group/format/#character-restrictions), I agree we should be able to reliably parse units from numbers in the JSON format.

> Parsing numbers and units from a string is trivial and performant in every programming language.

I only want to highlight one exception, specific to this Design Tokens Format Module. These character restrictions do not pair well outside of quoted strings in non JSON file formats like CSS.

Specifically, the reservation of `U+002E` — the **FULL STOP** or ‘period’ (`.`) character — may potentially introduce non-trivial parsing issues. This is because the period character also begins fractional numbers.

As niche or hypothetical as this sounds, I believe it has already surfaced in the wild. We can see the parsing conflict in this [video](https://www.twitch.tv/videos/1426433997) for a new and very impressive library that implements the Design Tokens Format Module in CSS ([at 00:43:31](https://www.twitch.tv/videos/1426433997?t=0h43m31s)). In that clip, there is a `red.6` token. In CSS, this is to be parsed as `red` and then `.6`. Extrapolating, a token like `red.6a50` could represent a naming pattern for alpha transparency, or it could represent `red`, then `0.6a`, and finally `90`. This means DTFM style tokens, if made declarable in CSS, will make parsing numbers and units non-trivial, unless quoted strings are also required. That would be my suggestion, anyway.

I think this is worth pointing out as folks experiment with DTFM outside of JSON. These are complex problems. And I have big time admiration for everyone I’ve just replied to or invoked. In fact, in the same clip ([at 00:50:44](https://www.twitch.tv/videos/1426433997?t=0h50m44s)), the same folks educate viewers on these same kinds of parsing issues. Y’all are good people who know your stuff. 🙂

-- 
GitHub Notification of comment by jonathantneal
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/121#issuecomment-1085228851 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 31 March 2022 23:30:02 UTC