Nim
Nim copied to clipboard
proc vs. method for OOP
Congratulations again for Nim!
I am experimenting with OOP in Nim. The article Let's Explore proc and method in Nim
shows that using proc instead of method can have the following impact:
In this case, since we were using
procs instead ofmethods, we simply called the incorrect render function in some cases. There would be no error raised, and we might not have even noticed the issue right away.
Would there be a better way to handle such situations in future versions of Nim? (error at compile time, etc.)
For the language to become more widely adopted, there might be a need for protections about such silent programming mistakes, what do you think? Are there already proposed solutions about this?
(For context: I am quite experienced in other languages, but the fact such situations can happen can be an obstacle to adoption)
Maybe explicit dynamic dispatch with methodCall in the vein of procCall. Could error if only procs found.