Group: type inheritance
Topic: casting a variable to a different type
Topic: data type compatibility
Topic: dynamic type checking
Topic: function call
Topic: object and value equivalence
Topic: real numbers and floating point numbers
Topic: restricted and extended types
Topic: structural equivalence vs. name equivalence of data types
Topic: translation of data
Topic: type hierarchy
Topic: type inheritance as reuse
Topic: units
Topic: weak vs. strong type checking
Topic: XML data type
| |
Summary
Values can be converted to equivalent types before use. For instance 12 inches converts to 1 foot, the letter 'A' converts to an ascii 61h, and the integer 1 converts to the real number 1.000. Type conversion may be a simple renaming. For instance a boolean 'false' and the integer 0 frequently have the same representation, or a list element may be an integer atom, or an indirect reference may be replaced by the referenced object.
Type conversion is needed for convenience but it weakens a type system. It is particularly needed for mixed mode arithmetic and constants. Alternatives to type conversions are explicitly typed constants and conversion indicators. (cbb 5/80)
Subtopic: conversion as part of data type
Note: a conversion is a form of typing; e.g., 'a(x)' can be interpreted as 'x is an a -- here's how' [»stroB_1991, OK]
| QuoteRef: wegbB5_1974 ;;27 type conversion as a component of a structure based on modes and converi
| Subtopic: inheritance
Quote: 'void*' is the root of the tree of class conversions; it is used if no other function matches a "more derived" class [»stroB_1994]
| Quote: assigning an extended type to a base type copies the shared fields only [»wirtN7_1988]
| Subtopic: structure conversion
Quote: C++ defines layout compatibility rules for structurally equivalent objects; allows explicit conversions for low-level services
| Subtopic: string conversion as portable representation
Quote: SUIT uses string conversion to save data types and to convert between types [»pausR10_1992, OK]
| Subtopic: unit conversion
Quote: units define equivalent values between two value sets [»chenPP3_1976]
| Quote: MicroTool converts engineering values into computer values with a scale factor, bias, and treatment of fractional units [»elshJL1_1991]
| Subtopic: endian conversion
Quote: efficient and optimal MD4-like hash functions on a Pentium processor; non-cached data and endianness conversion are not expensive [»bossA8_1996]
| Subtopic: boolean conversion
QuoteRef: sammJE_1969 ;;223 function to convert booleans to 1 or O
| Subtopic: cast and coercion
Quote: C's cast operator forces a conversion from one data type to another [»ritcDM7_1978c]
| Quote: coercions added to C++ because of natural mappings and use of mixed-mode arithmetic in numerical work [»stroB5_1989]
| Quote: typetest operators to test literals; e.g., 'isn x' is true if x is a number [»wirtN1_1966]
| Quote: conversion operators to convert values; e.g., 'real x' produces a real number
| Quote: use explicit conversion operators to avoid ambiguities; use implicit conversions for frequently used conversions [»stroB_1991]
| Subtopic: safe conversion
QuoteRef: schuSA_1970 ;;14 mode conversions eg mode complex is [real rp, real ip] with from real by x.[x, 0.0]
| Quote: a transferable data type can be converted to another format with no type checking [»morrJH_1974, OK]
| Subtopic: correctly rounded conversion
Quote: efficient algorithm for correctly rounded decimal-to-binary conversion; avoids high-precision arithmetic 99.6% of the time [»clinWD6_1990]
| Subtopic: mixed precision
Quote: strict evaluation is wrong for mixed precision expressions; e.g., 7.0/3.0*d should be all double precision [»farnC7_1988]
| Quote: use widest needed precision when evaluating mixed precision expressions [»farnC7_1988]
| Quote: need implicit conversions for mixed-mode operations; otherwise get a quadratic explosion of functions [»stroB_1994]
| Subtopic: automatic conversion
Quote: argument matching rules for C++: exact match, integral promotions, standard conversions, user-defined conversions, parameter ellipsis; must be unique at a level [»stroB_1991]
| Quote: Modula-3 allows implicit conversion only if it can be implemented by bit-copy; e.g., 'cardinal' to 'integer' but not 'real' to 'longreal' [»goldD6_1992]
| Quote: Modula-3 does not use ambiguous types, target-typing, or automatic conversions (except for packed fields, etc.)
| Subtopic: problems with automatic conversion
Quote: automatic conversion to smaller objects widely used; e.g., from 'int' to 'char'; could not remove from C++ [»stroB_1994]
| Quote: automatic type conversion is a bad idea because it reduces type checking [»clarBL9_1973]
| Quote: automatic type conversion does not work as intended; i.e., perform intended conversions while refusing to perform other conversions [»parnDL3_1976]
| Subtopic: problems with conversion
Quote: Modula-3's strict conversions requires separate representations for real, longreal, and extended literals; makes it difficult to write generic procedures [»goldD6_1992]
| Quote: multiple template arguments for arithmetic types can lead to an explosion of generated functions and code; should use explicit type conversion instead [»stroB_1991]
| Quote: wrong output despite the conversion of Cobol arithmetic into C [»tereAA11_2000]
| Quote: an endless list of annoying issues for converting between programming languages; e.g., different dialects of Cobol [»tereAA11_2000]
| Quote: converting programs from Cobol is difficult because of Cobol's rich set of constructions for sophisticated data-processing [»tereAA11_2000]
| Quote: converting a program to another language is always difficult; particularly with semantic equivalence and a rich source language [»tereAA11_2000]
|
Related Topics
Group: type inheritance (13 topics, 394 quotes)
Topic: casting a variable to a different type (7 items)
Topic: data type compatibility (5 items)
Topic: dynamic type checking (43 items)
Topic: function call (28 items)
Topic: object and value equivalence (60 items)
Topic: real numbers and floating point numbers (37 items)
Topic: restricted and extended types (35 items)
Topic: structural equivalence vs. name equivalence of data types (30 items)
Topic: translation of data (26 items)
Topic: type hierarchy (18 items)
Topic: type inheritance as reuse (27 items)
Topic: units (23 items)
Topic: weak vs. strong type checking (42 items)
Topic: XML data type (22 items)
|