C only please, no C++.
My eventual goal is to be able to translate Python into C to be compiled by the C compiler. As I see it there's two steps, create a dynamic typing library for C, and create the actual translator. I'm already working on a basic dynamic type and the results so far are good.
Here's the problem, in python the data in classes are created dynamicly, there's no way to predefine them. Here's some example Python code:
Python handles those dynamic class members (and all variables) with string-based hash tables. I wish to accomplish the same thing in C without the hash tables if possible. If I have to use hash tables could I use memory addresses instead of strings? Integer comparisons are much faster than string comparisons. Any ideas on how I can do this without hash tables?Code:#create an empty class named "person" class person: pass #create a "person" instance some_name = person() #assign data members to "some_name" some_name.name = "Homer Simpson" some_name.age = 39 #this is a guess, I'm not sure how old he is some_name.gender = "M" #print the newly assigned data print some_name.name, some_name.age, some_name.gender Homer Simpson 39 M
Thanks in advance.