Types |
|
Types in programming languages are inspired by mathematical set theory.
Basic Type SystemsDynamic TypesIn a language, such as J, with dynamic types and run-time type checking each value has a type and just as the value assigned to a variable can change so the type is allowed to change as the value changes, e.g.
Depending on the language, the action taken by an operator can vary with the type(s) of the operand(s), e.g.
-- assuming `+' represents both numerical addition and string concatenation. Static TypesMost compiled programming languages have static types and compile-time type checking, e.g.
Static type checking guarantees that a wide class of programming errors in which an operator is applied to the wrong type of operand cannot occur when the program runs. Static type checking also allows operators to be overloaded with different meanings, different code sequences, e.g.
and so on, as the language designer chooses. This is achieved with no run-time penalty. A programming language will provide some atomic types,
generally including Int, Real, Boolean, and Char, and
some structured types possibly including
array ([ ]), tuple (record, structure), Polymorphic Types...Type Classes...--2004, LA.
|
|
↑ © L. Allison, www.allisons.org/ll/ (or as otherwise indicated). Created with "vi (Linux)", charset=iso-8859-1, fetched Wednesday, 24-Apr-2024 06:55:26 UTC. Free: Linux, Ubuntu operating-sys, OpenOffice office-suite, The GIMP ~photoshop, Firefox web-browser, FlashBlock flash on/off. |