Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Clay: A new language for generic programming (based on LLVM). Parent comment
Your dispatch code now:
record Square { side : Double; } record Circle { radius : Double; } variant Shape = Square | Circle; procedure show; overload show(x:Square) { println("Square(", x.side, ")"); } overload show(x:Circle) { println("Circle(", x.radius, ")"); }
interface Shape { abstract procedure show(self); } record Square : Shape { side : Double; show(self) { println("Square(", self.side, ")"); } } record Circle: Shape { radius : Double; show(self) { println("Circle(", self.radius, ")"); } } variant Shape = Square | Circle;
There are no comments on this comment yet.
Your dispatch code now:
My "Objectivizing": Here, "abstract" declaration in the parent would make the children's "show" automatically become an overload. 'self' is variable which would be automatically specialized to the containing record. I think the resulting code isn't excessively verbose.