Type system
SkookumScript’s type system (type model) is powerful, flexible, safe, and gets out of the way as much as possible. Unlike many other scripting languages, SkookumScript is fully type-checked at compile-time, which catches many bugs before the game runs.
Typing | SkookumScript methodology |
---|---|
Inferred vs. Manifest | When context is available, types are inferred; otherwise, types must be manifest (specified) when needed. |
Static vs. Dynamic | Uses static type-checking during compile-time though has full dynamic type info during runtime and several dynamic syntax features. |
Strong vs. Weak | Strongly typed. |
Nominal vs. Structural | Uses nominal with nominal subtyping – types are known via inference or being explicitly specified rather than determining type by examining an object’s structure. |
Union Types | Uses union types. These can be specified explicitly <Class1|Class2> and also be auto-inferred based on alternate code paths. |
Duck Typing | Uses a limited form of duck typing: reduction of ‘nil’ and object(s) unions to just object(s). |
Latent Typing | Uses latent typing—types are associated with objects (values) rather than variables. |
Unified Type System | All class types have Object as a common (root) super class. |
Type Conversion | Explicit type casting expression<>SomeClass and type conversion expression>>SomeClass (type can be inferred if context available: expression<> or expression>> ). Implicit coercion is intentionally omitted to reduce unintentional conversion bugs. |