-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrand.grace
48 lines (33 loc) · 867 Bytes
/
brand.grace
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class square is aSquare { }
class rectangle is aRectangle { }
class brand {
print "WHOOPEE"
method retainedAnnotation { }
method Type { brandType(self) }
}
class brandType(underlyingBrand) {
method match(other) {primitiveBrandMatch(underlyingBrand,other)}
}
class And(l,r) {
method match(other) {
if (l.match(other))
then {r.match(other)}
else {false}
}
}
def aSquare = brand
def aRectangle = brand
def s = square
def r = rectangle
def SquareType = aSquare.Type
def RectangleType = aRectangle.Type
print "GOING"
print( primitiveBrandMatch(aRectangle, 12) )
print( primitiveBrandMatch(aRectangle, s) )
print( primitiveBrandMatch(aSquare, 12) )
print( primitiveBrandMatch(aSquare, s) )
print (SquareType.match(12))
print (SquareType.match(s))
print (RectangleType.match(s))
print (RectangleType.match(r))
print "done"