Why can you make assumptions about operation overloads but not functions?
Re:Deep Learning in JavaScript
by foolswisdom on Friday March 29, 2024 @10:03AM
(#39864237)
Because there is nothing to make assumptions about. In the example code, both multiplication and division have a scalar on one side, there's no possible ambiguity of behavior. But there is the eternal question of terminology: do you specify dimensions by "axis" or "dim" and does your API actually use both terms in different places?
(that's what I think the GP meant, anyway).
Re:Deep Learning in JavaScript
by throwaway4aday on Friday March 29, 2024 @10:30AM
(#39864537)
If each of those operators were implemented as functions then you'd have different names for different implementations in order to avoid confusion over what type of division or multiplication they were performing. It's more verbose but that's a good thing since it prevents you from making incorrect assumptions about what's going to happen when you do a * b.
In javascript, to write the same thing I need to read documentation for a sum function, a broadcasted division function, a multiply function. I can probably assume that the sqrt function behaves and is named as I would expect