logoalt Hacker News

efitz12/09/20241 replyview on HN

Type declarations can imply syntax, semantics or both.

Yes, you could represent everything as a string; in that case, the serialization format is no longer providing any assistance in verifying or enforcing syntax.

But it’s often useful to be able to verify syntax independently. And it helps avoid authoring errors (like using “1” instead of “true” etc.) that are ambiguous if your only hint is semantic.


Replies

eadmund12/09/2024

In that case one should also have a type for dates.

What I’m getting that is that a format ought to commit.