Very, very incomplete review:
A class is a structure (you know C / C ++, right?)
Methods are ordinary functions, except that they receive an additional implicit argument: the object itself. This argument is usually called 'this' or "self" inside the function. Scope symbols may (C ++, JavaScript) or may not (PHP, Python) be accessible by default within methods.
Inheritance essentially smoothes structures and, possibly, also joins symbol tables, since usually the characters of the base class are accessible by default from the methods of the class that you are currently parsing. When you come across a character (field or method) inside a method, you need to do an upward search, starting from the current class, ascending the hierarchy. Or you can implement it so that you view it in only one character table, which is the result of a merge.
Virtual methods are called indirectly. In some languages, by default, all methods are virtual. The implementation will depend on whether it is a fully dynamic language, in which case you always look at the function name inside the class at runtime, and therefore all your methods become virtual automatically; or in the case of static languages, compilers usually create so-called virtual method tables. I'm not sure you need this at all, so I will not go into details here.
Constructors are special methods that are called either when building a new object (usually using the "new" one), or are otherwise called part of the constructor's call chain from within the child constructors. Many different implementations are possible here, one of which is that the constructor takes an implicit argument of 'this', which can be NULL if the object has not yet been created, and returns it as well.
Destructors are ordinary methods that are usually called implicitly when an object goes out of scope. Again, you need to consider the possibility of an upstream call chain for destructors.
Interfaces are complex unless your language is fully dynamic.
mojuba
source share