2 ms·
How's that different than what other languages call 'inheritance.'
by GFK_of_xmaspast 12y ago
How's that different than what other languages call 'inheritance.'
- ScottBurson 12y agoBecause most node classes have their own slots. Consider this example: class Node {...} class Expression extends Node {...} class Addition extends Expression { Expression left, Expression right; Set<Node> children() { return [a set containing 'left' and 'right']; } } There's no way to write a single method 'children' on Node that will work for all its subclasses, because the method on Node can't access the subclasses' slots -- unless you use reflection, which is ugly and slow.