3 ms·
It's not just similar, templates are duck typed, they just happen to execute at compile-time. I have mixed-feelings about them. On one hand they have all the p
by sirwhinesalot 2y ago
It's not just similar, templates are duck typed, they just happen to execute at compile-time.
I have mixed-feelings about them. On one hand they have all the problems mentioned in the blog post and most of the ones from duck typing in general.
On another hand not needing to define protocols for every little thing is pretty nice.
I think a nice middle ground would be to structuraly type them. Have the compiler record in some interface file of some sort exactly which fields/functions must be available for the template to work.
But I don't think such a thing is feasible with the insane metaprogramming you can do in zig or even C++ (which is also turing complete, just incomprehensible)