|
|
| | Ask HN: Is there a way to define classes at runtime in any language? | | 3 points by Allocator2008 on March 28, 2009 | hide | past | favorite | 5 comments | | I was just thinking about chatbots, and the ability to make logical deductions. Like Men are Mortals, Socrates is a man, so Socrates is mortal. So Mortals could be the superclass, men could be the subclass, and Socrates could be an instance of the subclass men, and would be a member of superclass Mortals. But it would be nice to have a way of defining these classes at runtime, so in a chatbot if the user posed such a scenario to the chatbot, the chatbot could use some pattern matching, construct the classes on the fly, and figure out the relations, thereby sounding "intelligent". Can this be done? Classes made at runtime instead of compile time? |
|

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
|
You can also use "new.classobj(name, bases, dict)" -- not quite sure what the difference is.