Section 35
Want more of a challenge? View in
iconic
form (
experimental
)
# OBJECT an example object -- a 2D point
[
hear
]
(define point
(lambda
(x y)
(reflective
(lambda
(self msg)
(cond
(
(=
(msg)
x)
(x)
)
(
(=
(msg)
y)
(y)
)
(
(=
(msg)
point)
(self)
)
(
(=
(msg)
+)
(lambda
(
(p point)
)
(point
(+
(x)
(p x)
)
(+
(y)
(p y)
)
)
)
)
(
(=
(msg)
=)
(lambda
(
(p point)
)
(and
(=
(x)
(p x)
)
(=
(y)
(p y)
)
)
)
)
0)
)
)
)
);
[
hear
]
(define point1
(point 1 11)
);
[
hear
]
(define point2
(point 2 22)
);
[
hear
]
(= 1
(point1 x)
);
[
hear
]
(= 22
(point2 y)
);
[
hear
]
(= 11
(
(point 11 12)
x)
);
[
hear
]
(= 11
(
(
(point 11 12)
point)
x)
);
[
hear
]
(= 16
(
(
(point 16 17)
point)
x)
);
[
hear
]
(= 33
(point1 +
(point2)
y)
);
[
hear
]
(point1 +
(point2)
=
(point 3 33)
);
[
hear
]
(point2 +
(point1)
=
(point 3 33)
);
[
hear
]
(
(point 100 200)
+
(point 200 100)
=
(point 300 300)
);
[
hear
]
(instanceof point
(point1)
);
[
hear
]
(not
(instanceof int
(point1)
)
);
[
hear
]
(instanceof int 5);
[
hear
]
(not
(instanceof point 5)
);