racket/collects/honu/examples/old/square.honu
Stevie Strickland 7dbb99d3c6 merged 292:296 from branches/sstrickl
svn: r297
2005-07-02 04:03:02 +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;
}