4 ms·
This is not easy to do in say Java which is significantly different from clojure (or how typescript enforces typing). In your example it appears that you're usi
by vikiomega9 9y ago
This is not easy to do in say Java which is significantly different from clojure (or how typescript enforces typing). In your example it appears that you're using the name field rather than the type Named to shape data that the function will use (this is in essence ducktyping)
- andrewflnr 9y agoRight, but that's nothing to do with types in general, mostly just Java and friends with unimaginative type systems.
- frankpf 9y agoI am using `Named` as an argument. In structural type systems, what matters is the type structure. It's not duck typing because it's checked at compile-time. If I change the type of "Named" to have the fields `firstName` and `lastName` of type string, accessing any other property inside `f` (like `obj.nonExisting`) or passing objects that don't have those fields.
- vikiomega9 9y agothanks! just to clarify, how do you manage the composition of these types? Do you create a structural type per API and potentially have the "same" types repeated multiple times?