[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
Misc:
[2001S]
[2002F]
[SamR]
Back to Type Checking (2): Type Equivalence. On to Stack Frames (1).
Held: Monday, 5 April 2004
Summary: Today we continue our explorations of type checking and type equivalence with some examples from C and some further questions.
Related Pages:
Overview:
I thought you might enjoy this quote from Kernighan & Ritchie (2nd edition, p. 198).
Many operators cause conversions and yield result types in a similar way. The effect is to bring operands into a common type, which is also the type of the result. This pattern is called the usual arithmetic conversions
First, if either operand is a
long double, the other operand is converted to along double.Otherwise, if either operand is a
double, the other is converted todouble.Otherwise, if either operand is a
float, the other is converted tofloat.Otherwise, the integral promotions are performed on both operands; then, if either operand is
unsigned long int, the other is converted tounsigned long int.Otherwise, if one operand is
long intand the other isunsigned int, the effect depends on whether along intcan represent all values of anunsigned int; if so, theunsigned intoperand is converted tolong int; if not, both are converted tounsigned long int.Otherwise, if one operand is
long int, the other is converted tolong int.Otherwise, if one operand is
unsigned int, the other is converted tounsigned int.Otherwise, both operands have type
int.
Wasn't that fun?
the samefor purposes of calls and assignment.
type t0 = record a: integer; b: integer end; t1 = record a: integer; b: real end; t2 = record a: integer; b: real end; t3 = record b: real; a; integer end; t4 = record c: integer; b: real end; t5 = record a: integer; b: real; c: integer; end; t6 = t1; var v0: t0; v1: t1; v2: t2; v3: t3; v4: t4; v5: t5; v6: t6; v7: record a: integer; b: real end; v8,v9: record a: integer; b: real end;
constantsin a type.
Back to Type Checking (2): Type Equivalence. On to Stack Frames (1).
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Instructions]
[Links]
[Search]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
Misc:
[2001S]
[2002F]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed May 5 11:47:10 2004.
The source to the document was last modified on Tue Jan 20 23:06:46 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2004S/Outlines/outline.27.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby