Skip to main content

How can I implement object oriented programming in Mathematica?


Roman Maeder's object oriented programming package is nice, but I'm hoping someone can suggest a sleek and novel implementation that is easy to use.



Answer



Well, one obvious idea would be to build on the struct implementation by Bob Beretta. You would have to add information about methods and modify the implementation of --> to consider those as well, and for polymorphism, you'd also have to store the base class (or base classes, if multiple inheritance should be supported), and have --> look there if the field or method is not found.


Comments