3 ms·
Nim supports runtime polymorphism, you need to use the ``method`` keyword instead of ``proc`` to achieve dynamic dispatch. (https://nim-lang.org/docs/tut2.html#
by cyber_kinetist 5y ago
Nim supports runtime polymorphism, you need to use the ``method`` keyword instead of ``proc`` to achieve dynamic dispatch. (https://nim-lang.org/docs/tut2.html#object-oriented-programming-dynamic-dispatch https://nim-lang.org/docs/tut2.html#object-oriented-programm...)
Note that at one point it could even do multi-methods (dynamic dispatch on multiple arguments at once), similar to what Julia could do. But this got removed because it complicated the language, had undesirable performance penalties, and was overall hard to maintain (https://github.com/nim-lang/RFCs/issues/65 https://github.com/nim-lang/RFCs/issues/65). It's still available via a flag, but might get eventually removed at some point.
Overall, I view Nim as more of a procedural language in the spirit of C/Pascal rather than the OOP-isms of old C++ / Java.