Hacker News new | ask | show | jobs
by InitialLastName 1739 days ago
>... it requires exporting an enum to all call-sites. Both in C++ and in python this is not desirable.

Given the reasonable namespacing that C++ and python [modules] provide, and that you have to export the complete calling specification of the function to the caller anyway (whether it's an enum, a positional boolean or a keyword argument), what's the drawback of the enum option?

1 comments

In Python, if you use ' import x from' now it becomes 'import x, y from'. Can especially make refactoring more work.

If you use namespaced imports then the call is going to become very long by having the package name included twice.

In C++ you are dealing with needing to drop the enum in a header file, requiring a two file change and making headers bigger. The call-side has the same potential namespace problem, but less badly.