3 ms·
I'd argue that a rich type system shifts logic errors into syntax error. An easy example is time arithmetic. Adding seconds to minutes can be problematic. If yo
by phamilton 11y ago
I'd argue that a rich type system shifts logic errors into syntax error. An easy example is time arithmetic. Adding seconds to minutes can be problematic. If you have proper types defined (in any language, pythons types do fine for this) then you need to confirm that addition of minutes and seconds is correct in one place, and the type system will guarantee it's done correctly throughout your code.
A richer type system allows you to move more logic into type system.
- paulddraper 11y agos/syntax/type/
- deleted 11y ago[deleted]
- agumonkey 11y agoSomehow somewhere it's the same, there's some expressions that you cannot write based on the rules you declared.
- paulddraper 11y agoTypically, a syntax is specified by BNF or similar. Every programming language has syntax, not every programming language has static types. I think you can separate these pretty cleanly.
- dllthomas 11y ago> I think you can separate these pretty cleanly. You can, and probably should, but it's more of an engineering distinction than a theoretical one. Syntax and types are both rules for how phrases can fit together. And sometimes it blurs - I understand that at least one C++ compiler parses with an overly general parser, collecting several results and disambiguating with type information. > Every programming language has syntax, not every programming language has static types. Not every programming language has "static syntax" - some allow you to adjust the parser, and some don't do any checking of the whole file (much less the whole program) before they start running the first bits of it.
- phamilton 11y agoFor the record, it was a typo on my part, though I do like this discussion.