racket/collects/honu/examples/square.honu
2005-05-27 18:56:37 +00:00

39 lines
741 B
Plaintext

/* This should parse and type-check correctly.
Note the field initialization in unitSquare: the declaration of the
field x should shadow the init arg x from that point forward, but
of course the RHS of x's declaration should refer to the init arg.
*/
type shape
{
int x;
int y;
int area();
}
type square extends shape
{
int length;
}
class unitSquare() : shape impl shape, square
{
init int x;
init int y;
int x = x;
int y = y;
int size = 1;
int area() { size * size; }
export shape : x as x,
y as y,
area as area;
export square : x as x,
y as y,
area as area,
size as length;
}