Remember that mixed type class that I was working on a long time ago?
Here's my scenario:
- The value for the variable is stored in a void pointer with an integer to decide which type is currently stored. When the variable is typecasted, the value is casted the the proper type using a function (returning an error if it can't be).
- To cast types, a 2-dimensional array of "cast functions" is provided. Each type that is supported is given an ID, and cast_functions[from][to] will provide the proper function to cast a void pointer from one type to another. Invalid IDs, etc. return errors.
Here's the problem:
- For operators, you don't know what the type is, and thus, you can't exactly add two types together. If you're adding mixed to a different type, you can use that type, but mixed and mixed? It can't be done.
The only solution that I can think of for this is to create an array of functions for each operation, and that would result in a massive size; is there anyone with other suggestions for this?