Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Because 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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: