20-CS-4003-001 Organization of Programming Languages Fall 2018
Types

Lambda calculus, Type theory, Formal semantics, Program analysis

Prev     Next     All lectures

Built-in primitive data types

Java:

 boolean - Logic value (true/false). byte - Two's complement integer value occupying 1 byte. char - Unicode value occupying 2 bytes. short - Two's complement integer value occupying 2 bytes. int - Two's complement integer value occupying 4 bytes. long - Two's complement integer value occupying 8 bytes. float - Real value limited to 32 bits (single precision). double - Real value limited to 64 bits (double precision). String - Array of characters of unlimited size - not a primitive data type. BigInteger - Integer of unlimited size - not a primitive data type.

 Bool - Logic value (true/false). Char - Unicode value occupying 2 bytes. Int - Two's complement integer value typically occupying 4 bytes. Integer - Integer of unlimited size. Float - Real value limited to 32 bits (single precision). Double - Real value limited to 64 bits (double precision). [Char] - Array of characters of unlimited size. Ordering - A type that can be "less than", "greater than", or "equal to" Type classes Eq - Includes any type where equality comparison makes sense (e.g. Integers) e.g. ghci> :t (==) results in (==) :: Eq a => a -> a -> Bool Ord - Includes any type where elements can be compared (<=, >=, etc. apply) This is a superset of the Eq class Show - Includes any type where elements can be displayed as a string e.g. ghci> show 3 results in "3" Read - Includes any type. The associated read function gets confused easily. The read function takes a string as argument, the return value is either inferred or explicitly given and belongs to the Read class. e.g. ghci> read "3" results in an error (of confusion) ghci> read "3"::Int results in the number 3 ghci> read "3"::Float results in 3.0 ghci> read "'A'"::Char results in 'A' ghci> read "4" + 2 results in 6 (type inferred) Enum - Includes any type where elements can be enumerated. Functions pred and succ are defined. Includes types (), Bool, Double, Float, Integer, Int, Char, Ordering Bounded - Includes any type where elements have a finite range of values. Functions minBound and maxBound are defined. e.g. ghci> minBound :: Bool returns False ghci> maxBound :: Bool returns True Num - Includes any type where elements can act like a number. Integral - Includes classes Integer and Int. Floating - Includes classes Double and Float.

Scheme:
 Booleans - Atomic values (#t / '()). Characters - Atomic symbols such as #\a. Numbers - Integers of unlimited size, also complex numbers like 1+2i. Strings - Double quoted list of characters. Cons pair - Pair of two objects. Lists - String of any number of objects ending in a null object. Procedures - Procedures are first-class objects - they can be passed as arguments and returned as values.