News for hackers. Stuff that matters.
Re:Clay: A new language for generic programming (based on LLVM) by kssreeram on Monday July 26, 2010 @07:55AM (#1547741)
Hi folks, I'm the author of Clay. There aren't any docs ready yet, but I'll try to answer whatever questions I can. Also, there's a long thread over at reddit with many interesting questions.

http://www.reddit.com/r/programming/comments/ctmxx/the_clay_...

Re:Clay: A new language for generic programming (based on LLVM) by joe_the_user on Monday July 26, 2010 @04:25PM (#1549157)
I couldn't help imagining how OO "objects" might be implemented in Clay

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, ")"); }

My "Objectivizing":

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