3 ms·
> Is there any advantage to "gluing" the functions to the data? Depends on the capabilities of the language. If the language supports function overloading and
by qayxc 5y ago
> Is there any advantage to "gluing" the functions to the data?
Depends on the capabilities of the language. If the language supports function overloading and type-checking, then no.
Otherwise the "fun" begins if you add different variations of the same basic data that require subtle changes for working with them.
In the case of Python you'd end up with a manual type-checking pattern and nested if-else statements within the functions. In the OO case you can leverage protocols, composition and (to a lesser extent) inheritance.