News for hackers. Stuff that matters.
Re:OOP Is Dead, Long Live OOP by kazinator on Thursday October 18, 2018 @03:20PM (#18251313)
Inheritance can be so randomly abused as just a code saving hack.

Look how I abused inheritance in this assembler (for a Lisp virtual machine):

http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib/asm.tl

The object system is used to define opcodes. Methods on these objects (which get instantiated as singletons) then handle assembling and disassembling.

There is a macro defopcode-derived which defines an opcode similar to another one, using inheritance.

There is no reason for the relationship to go one way or the other; it's just "this thing is like that thing, except for this slight difference". The inheritance could basically go in either direction.

Note that defopcode-derived doesn't even have provision in its syntax to specify behavior; the code is 100% re-used. The only thing different about the derived opcode is the instruction mnemonic and the opcode bits. Inheritance is used just to override a number and symbol which are static slots.

There are no comments on this comment yet.