by mirekrusin · 3y ago · 0 comments
This problem is much bigger. You can for example easily imagine api where you provide where clause that is converted to sql form. You may declare type to expect only certain parameters, but it won't help you at the type level as anything extra can be passed. This can be abused to extract some sensitive information.
You're forced to emulate exactness by always destructuring objects - not great.
You're forced to emulate exactness by always destructuring objects - not great.
It’s almost like using objects as enumerable maps is an anti-pattern.Zig does it the right way - it's defined in zig itself, no special cases in compiler like in Rust.
This is not meant as an argument against what you’re saying, because I know you were just giving an example, but I found this and thought you may find it interesting: https://www.hacklewayne.com/a-truly-strongly-typed-printf-in...
1. nominal types for classes (with correct variance/liskov substitution principles)
2. structural types for the rest
3. explicit annotation for exact structural types
This setup is brilliant.