This section presents conventions used throughout the standard Sather libraries. Some conventions regard naming, while others dictate subtyping from certain abstract classes in the base library. Adhering to these conventions allows code from independent developers to be used together and makes code easier to understand.
Sather provides a special syntactic sugar (See Syntactic sugar expressions) for calls to the routine 'create', which nearly all classes define. It is often convenient to overload 'create' routines to do conversion between types as well.
Example 14-1. This is the canonical 'create' routine, which simply returns an uninitialized (See new expressions) object.
create:SAME is return new end
Example 14-2. This is a 'create' routine for an object with an array portion. Such objects require an integer argument to 'new'. This example creates a new object with 10 array elements indexed zero through nine.
create:SAME is return new(10) end
Example 14-3. This 'create' routine converts a string to an object. This could be used in combination with still other create routines to convert from different types.
create(arg:STR):SAME is ... end
All three create routines shown could be invoked with the '#' sugar (See Creation expressions).