TopMore conditionalsTypes in Grace

Types in Grace

Define types. Show types in Appendix to Programming in Grace or on documents page on course web page..

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.

Look at the documentation for Number and Point to see what you can do with them. Both types represent immutable objects. They cannot be modified, but there are methods that return new values.

Documentation for objectdraw is found in another appendix to the text or via the documentation page.

We also discussed how to use methods and classes from other modules. In particular we discussed the method elapsed from built-in module "sys". See also the Math library in section B.4 of text.

Two other programs discussed are ClickTimer and MorseCode

The ++ operator on String is concatenation.


TopMore conditionalsTypes in Grace