2 ms·
> Why can't a "dog" be a perfectly ordinary data structure that you manipulate the usual way? In statically typed languages, it's easier to read data out of a
by nyanpasu64 5y ago
> Why can't a "dog" be a perfectly ordinary data structure that you manipulate the usual way?
In statically typed languages, it's easier to read data out of a struct with fixed types, than a map[string]any and convert it to the expected type on each access.
> So you end up with an abstract type (dog) and a bunch of functions that operate on that abstract type.
C has no multiple dispatch and no classes. So libraries based around opaque objects (GTK and ALSA etc.) prefix each function name with its struct name, which is verbose and gets tedious to read or write after a while. Is multiple dispatch possible in a statically typed languages with compile-time nonvirtual function resolution? I haven't looked into it, it might be possible.