racket/collects/honu/examples/old/point.honu
Stevie Strickland 7dbb99d3c6 merged 292:296 from branches/sstrickl
svn: r297
2005-07-02 04:03:02 +00:00

57 lines
986 B
Plaintext

/* Again, should parse and typecheck, though watch out for constructor
* syntax.
*/
type Point
{
int x;
int y;
}
type ColorPoint extends Point
{
int color;
}
type MovingPoint extends Point
{
float dx;
float dy;
}
class PtClass() : Point implements Point
{
init int x;
init int y;
export Point : x as x, y as y;
}
class ColorPtClass() : ColorPoint implements Point, ColorPoint
{
/* We should add syntactic sugar for init fields. */
init int x;
init int y;
init int color;
export Point : x as x, y as y;
export ColorPoint : x as x, y as y, color as color;
}
mixin makeMovingPoint() : MovingPoint at Point impl MovingPoint
{
init float dx;
init float dy;
super();
export MovingPoint : x, y, dx, dy;
}
subclass MvPtCls = makeMovingPoint(PtClass);
subclass MvClrPtCls = makeMovingPoint(ColorPtClass);
MovingPoint main() {
new MvClrPtCls : MovingPoint(x = 3, y = 4, color = 42, dx = 0.4, dy = -3.2);
}