Topic: casting a variable to a different type
Topic: consistency testing
Topic: dynamic vs. static data type
Topic: early vs. late binding
Topic: range checking
Topic: restricted and extended types
Topic: ref_any or Object data type
Topic: run-time assertions
Topic: self-identifying data structures
Topic: type conversion
Topic: variant data types
Topic: weak vs. strong type checking
| |
Summary
When the type of a variable can not be determined at compile-time, the type check is either ignored or delayed until program execution. Dynamic type checks are needed for variant types, type valued variables, range types, and incomplete types. Incomplete types arise when an operation applies to less than a full type, for instance division invalid at zero, or array indexing which is inapplicable outside of the array's bounds. (cbb 5/80)
In object-oriented databases, the database manager can catch type errors at modification time instead of transaction commit. (cbb 1/90)
Subtopic: dynamic vs. static types
Quote: the difference between dynamic and static type checking is the difference between "x must be a car" and "x is a car" [»stroB_1991]
| Quote: static type-checking may not catch type errors due to subclassing a function argument [»alexRT1_2000]
| Quote: with static typing can detect procedure-call errors early but lose generic procedures and requires type declarations [»teslL8_1981]
| Subtopic: class invariant
Quote: check routines for class invariants are an invaluable help during debugging and class definition [»stroB_1991]
| Quote: production code should include some of the check routines for class invariants
| Quote: type consistency should be checked as soon as sufficient information is available; unifies static and dynamic typing [»heerJ4_1985]
| Subtopic: input validation, argument checks
Quote: in an improperly functioning system, procedures can get unexpected data [»robsD8_1981]
| Quote: with a weakly-typed language, inconsistencies are not caught until run-time
| Quote: while some operators apply to many types, others apply to restricted types, e.g., division [»hehnEC7_1975]
| Quote: some values of composite types are invalid; need run-time checks, e.g., array bounds [»kiebRB9_1973, OK]
| Subtopic: type cast
Quote: use TYPECASE to test the referent type of any traced object [»cardL_1991]
| Quote: fast dynamic casting using 64-bit type ID and a prime number for each class; requires whole program analysis, e.g., embedded system [»gibbM2_2006]
| Subtopic: reflection
Quote: use display mechanism for run-time access to extended type descriptors; construct at compile time [»coheNH10_1991]
| Quote: C++ run-time type mechanism: 'dynamic_cast' from a base class, an explicit 'typeid', and implementation 'type_info' [»stroB_1994]
| Subtopic: fully-checked language
Quote: PL.8 not standardized despite being a fully-checked language; enforcement of language rules cost less than 10% [»auslM6_1982]
| Quote: PL.8 guarantees that all array and offset references are within bounds; optimizes run-time checks; checking costs 5-10% [»auslM6_1982]
| Quote: Cyclone is a safe dialect of C; avoids buffer overflows, format string attacks, and memory management errors; static analysis plus run-time checks and annotations [»jimT6_2002]
| Quote: Cyclone has growable memory region, tagged union, polymorphism, and exceptions
| Subtopic: input validation
Quote: a system should be intelligent, i.e., help the user and reduce workload; e.g., check all inputs for validity [»potaWA_1979]
| Quote: a function interface should lead to correct code; avoid multiple returns, error values, and multipurpose functions; allow strong argument validation [»maguS_1993]
| Quote: a validated element must match its type, since validation yields sensible values; consequence of pure named typing [»simeJ1_2003]
| Quote: validation methods are primarily used as bug-finders; formal methods are useful because they find different bugs than traditional methods; a more realistic goal than guaranteeing correctness [»dillDL4_1996]
| Quote: enforce type system with run-time validation checks on each argument; e.g., all file names belong to the /tmp directory
| Subtopic: type tests
Quote: typetest operators to test literals; e.g., 'isn x' is true if x is a number [»wirtN1_1966]
| Subtopic: pointer and array tests
Quote: Cyclone has never-NULL pointers (@...) and fat pointers (?...) with run-time checking (e.g., varargs) [»jimT6_2002]
| Quote: check all pointer and array accesses with an extended safe pointer representation; 2-6x time cost, less than 2x space cost [»austTM6_1994]
| Quote: safe pointer representation with base address, size, storage class, and liveness property; check all accesses with unnecessary checks avoided via runtime tests [»austTM6_1994]
| Quote: SafeTSA includes safe-ref that cannot be null, and safe-index-arr that cannot be out of range; via runtime checks [»ammeW6_2001]
| Quote: an application can test the validity of a link and correct the link if necessary [»ashmH9_2000]
| Subtopic: memory access test
Quote: use the page fault handler to implement quick page accessibility tests; a page fault only occurs on a negative answer [»liedJ1_1994]
| Subtopic: subtype test
Quote: subtype testing via PQ-trees; small footprint, constant time; originally used in constraint ordering [»zibiY10_2001]
| Subtopic: dynamic types
Quote: object-oriented database can check method arguments at invocation instead of at transaction commit [»smitKE10_1987]
| Quote: since variables do not have a static type; the Smalltalk compiler can not detect message errors at compilation [»teslL8_1981]
| Quote: inheritance allows for polymorphic variables to become attached at run-time [»meyeB9_1990]
| Quote: an entity is declared with a static type and associated with a dynamic type at runtime; all dynamic types must be descendants
| Subtopic: message not understood
Quote: Smalltalk is safe since type mismatches ('message not understood') are reported with a notify window [»teslL8_1981]
| Quote: most common Smalltalk error is 'message not understood' [»teslL8_1981]
| Subtopic: flavor -- type properties
Quote: a flavor is a property of an object that changes during program execution; e.g., 'total' may be initialized, partial sum, total sum [»howdWE1_1990]
| Subtopic: avoiding dynamic type checks
Quote: SafeTSA is compact, type-safe mobile code based on static single assignment; safe by construction with referential integrity, type separation, and type check elimination [»ammeW6_2001]
| Quote: use typeflow analysis to detect errors and reduce dynamic type testing of Oberon-style types [»cornD3_1994]
| Quote: runtime overhead of PQL ranges from 9% to 125%; static analysis helps a lot; max is 19x slowdown [»martM10_2005]
| Subtopic: problems with dynamic type checking
Quote: dynamic type checking underspecifies an interface; it makes an assumption that is checked at runtime
| Quote: dynamic type checking can make a program run 3 to 10 times slower than the same program with static type checking [»stroB_1991]
|
Related Topics
Topic: casting a variable to a different type (7 items)
Topic: consistency testing (60 items)
Topic: dynamic vs. static data type (24 items)
Topic: early vs. late binding (15 items)
Topic: range checking (20 items)
Topic: restricted and extended types (35 items)
Topic: ref_any or Object data type (9 items)
Topic: run-time assertions (25 items)
Topic: self-identifying data structures (18 items)
Topic: type conversion (33 items)
Topic: variant data types (7 items)
Topic: weak vs. strong type checking (42 items)
|