TopTypes in Grace

Types in Grace

Define types. Show types in Appendix to Programming in Grace.

Right now we are just using predefined types, but will soon be making up our own.

All vars and refs should have associated type, while methods must have types on parameters as well as return types.

Why define types:

Aside from the objectdraw types, there are also predefined types in Grace like Point, Number, String, Boolean, and Done. The definitions of the first three are given in this chapter of the text. Done simply indicates that there is no value to hold or return. It is often used as a return type from methods that do something, but don't return a value.

Example: Here is a typed version of Basketball where we drag around something that looked more like a real basketball.

We also discussed how to use methods and classes from other modules. In particular we discussed the method elapsed from built-in module "sys"

Two other programs discussed are ClickTimer and MorseCode


TopTypes in Grace