IssueRaiser

Because most node classes have their own slots.

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.

Posted by ScottBurson on May 8, 2015, 1:16 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.6,500 issues0 comments

hackernews (Other)

Because most node classes have their own slots.

ScottBursonMay 8, 2015, 1:16 AM

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.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue