T.R | Title | User | Personal Name | Date | Lines |
---|
347.1 | Bit-preserving vs semantics-preserving | TLE::JBISHOP | | Fri Dec 18 1992 16:14 | 17 |
| It depends on who you ask (I believe C has different meanings),
but from the VAX Pascal perspective,
o casting is an explicit request to re-interpret a set of
bits (which are the representation of a particular value
of a particular data-type) as being a representation from
a different data-type, e.g. You put 3.14159 into a float
and then view it as a character string (and get nonsense);
o coercion is the implicit conversion of one data-type to
another in such a manner that the "meaning" is maintained,
e.g. you put 3 into an integer and then multiply it by
2.1 (a float), so the the 3 is coerced into 3.0. Note
that the bit pattern representing 3.0 can be quite different
from that which represents 3.
-John Bishop
|
347.2 | Casting a gauntlet | TLE::AMARTIN | Alan H. Martin | Mon Dec 21 1992 22:34 | 12 |
| Re .0:
I agree with your definitions, for both C, and in general.
Re .1:
I daresay the definition of "casting" you attribute to the VAX Pascal
perspective is commonly known as "representational viewing". Also, no decent
context comes to my mind where it has that definition you give. (Ask me what
indecent context in which it arose). Got any good references?
/AHM/THX
|
347.3 | Pascal doc set good enough? | TLE::JBISHOP | | Tue Dec 22 1992 10:30 | 9 |
| _Programming_in_VAX_PASCAL_, section 7.2.6, p 7-12:
"...the actual representation of the object being cast is never
altered by the type cast operator."
There's an example of casting a float as a record to look at the
mantissa, etc.
-John Bishop
|
347.4 | VAX Pascal ftagn? | TLE::AMARTIN | Alan H. Martin | Tue Dec 22 1992 12:13 | 6 |
| Re .3:
Thanks, that's as horrifically authoritative as one could want. Pray tell, is
this feature (or nomenclature) part of any ISO Pascal standard, or adopted
from another vendor's Pascal, or is it a Digital extension?
/AHM/THX
|
347.5 | What level magician are you? | STEVEN::HOBBS | | Mon Dec 28 1992 10:31 | 16 |
| The VAX Pascal concept of a "cast" came from an early definition of
Ada. There are "casts" and there are "conversions". Conversions are
what programmers usually do; casts are what magicians usually do. In
a conversion, the interpretation of the value never changes although
the representation may change. In a cast, the representation never
changes although the interpretation of the value may change. (Note
that sometimes programmers are also magicians when they need to cast a
spell over a particularly recalcitrant piece of data).
The VAX Pascal use of "cast" is in conflict with the Algol-68 use of
the term. In Algol-68, a cast always had the semantics of a
conversion of some sort. In C, the term cast is not used uniformly.
In some cases, a cast in C will change the representation without
changing the value while in other cases a cast in C will change the
value without changing the representation. (On the other hand, C is a
language for magicians whose spells don't always work).
|
347.6 | Digital has it now | TLE::REAGAN | Use only as directed | Tue Dec 29 1992 13:54 | 3 |
| See also BLISS' MAP declaration. Just a "cast" with a scoped syntax.
-John
|
347.7 | | TLE::REAGAN | Use only as directed | Tue Dec 29 1992 13:56 | 3 |
| Also, Apollo's Pascal has real "casts" instead of "coercions".
-John
|
347.8 | Which portable C casts view representation? | TLE::AMARTIN | Alan H. Martin | Tue Dec 29 1992 15:23 | 8 |
| Re .5:
>... in other cases a cast in C will change the value without changing the
>representation.
Offhand, the only such cases I can recall all involve overflow, and are thus
*not* defined by K&R, or ANSI C.
/AHM/THX
|