Suggestion: If you drop support for older Python, then you can add type hints #183
Replies: 5 comments 2 replies
-
This actually violates one of the "mantras" (https://github.com/arizvisa/ida-minsc/wiki/Mantras#object-oriented-programming-and-schemas-suck-due-to-me-having-to-memorize-them-along-with-parameter-order) The way the entire library is written is so that each function is type-insensitive. This is one of the core concepts of this library and avoids you having to think about types when all you know is that you have a "something" that might be a number, a range, or a name. To give credit, this is inspired from pattern matching that is found in some functional and logic-oriented programming languages. The idea is due to the fact that most of your reversing artifacts are going to be an integer or a string (perhaps with some metadata attached to it). Hence, the library aims to hide the concept of "types" from you. For example, if you want a function you can reference it by integer, a name, The reason this is done is because most of your good work is going to be confirming things while debugging...which uses addresses and offsets as opposed to some type that you'll need to exchange with another interpreter. If you prefer to use something that is object-oriented and not oriented around functional-programming, there are IDA libraries that actually are type-sensitive. Specifically SynAcktiv's BIP which is more recently maintained, and then there's Sark which was written a little while ago but still actually works (afaik). Although, I definitely think you should reconsider why you desire type checking for scripting your reverse-engineering tasks. To clarify, I don't mind types...I just don't think they're relevant for all problems. It's probably relevant to note that historically Python figured the same as they decided that it should be done during runtime before adding support for static type checking. |
Beta Was this translation helpful? Give feedback.
-
So I have basically the same philosophy that the use do not want to know the types but let the code do whatever makes sense. I have however another approach than you that I have code that looks like this:
This will fulfill the same idea as your multicase but with type hints and I can now do checks that whatever comes into my function address() is something that I can handle. |
Beta Was this translation helpful? Give feedback.
-
Converted to discussion. |
Beta Was this translation helpful? Give feedback.
-
We have the same goal but different paths to get there. It was just a suggestion. |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion as it seems to be just a coding style disagreement. |
Beta Was this translation helpful? Give feedback.
-
This will increase the readability and static type checkers such as mypy can be used.
Beta Was this translation helpful? Give feedback.
All reactions