Sep 24, 2003 ------------- - More on types - enumerated types - subrange types - what are these a special class of? - Enumerated types - are they considered a special type, or - are they just thought of as aliases for integers? - If latter, - can enum be coerced into int? - can int be coerced into enum? - Can an enum const appear in many definitions? - Examples - Pascal, C: enums allowed in only one ref. environment - Ada: enums allowed in many ref. environments - Java: no enums - Can you do operations on enums? - e.g., + - A staunch "no" in Ada! - Subrange - contiguous subsequence of an ordinal type - e.g., type digit=0..9; in Pascal - meaningful only when succ() and pred() functions apply - type num=0.0..1.0 doesn't make sense! - why? - somebody must do range-checking - Arrays - can be thought of as function from indices to values - exactly how Ada treats it! - Ada uses () for both arrays and functions - Examples of array storage schemes - equations for lookup - row-major ordering (e.g., C) - column-major ordering (e.g., FORTRAN) - Different types of arrays, in terms of - subscript range binding - storage location binding - (subscript range, storage location) tuples - (static, static): static arrays in C - (static, declaration-bound dynamic): regular arrays in C - (dynamic, runtime-fixed): Java - (dynamic, dynamic): Perl - Languages with more sophisticated array support - Matlab (can do some pretty cool things) - APL - Jagged arrays - e.g., periodic table