− Syntax and semantics
− Naming, scopes and bindings
− Control flow
− Data types
− Subroutines - answers✔✔General issues in the design and implementation of a language:
Mechanism for defining types (syntax, semantics)
− Rules for:
− type equivalence (when are the types of two values the same?)
− type compatibility (when can a value of type A be used in a context that
expects type B?)
− type inference (what is the type of an expression, given the types of the
operands?) - answers✔✔A type system consists of:
ensure that a program obeys thecompatibility rules - answers✔✔Type checking
violation of compatibility rules - answers✔✔Type clash
− Strong typing - language prevents you from applying an operation to data for which it is not
appropriate
− Static typing - language has strong typing, and it does type checking at compile time
− Dynamic typing - type checking done at run time - answers✔✔A language may have:
language prevents you from applying an operation to data for which it is not appropriate -
answers✔✔Strong typing
language has strong typing, and it does type checking at compile time - answers✔✔Static typing
, type checking done at run time - answers✔✔Dynamic typing
− Scheme - strong typing, but dynamic
− Smalltalk - strong typing, but dynamic (operations <=> messages
sent to objects)
− Ada - strong and static typing
− Pascal - "almost" strong and "almost" static typing
− C - weaker than Pascal, but static (not much done at run time)
− Java - strong typing, part done at compile time, part at run time - answers✔✔Type Systems Examples
collection of values for a domain - answers✔✔Type: Denotational
internal structure of data, described down to the level
of fundamental types
− built-in types (integer, character, real, etc), also called primitive or
predefined types
− composite types (array, record, set, etc) - answers✔✔Type: Constructive
interface that specifies the operations that can be applied to objects - answers✔✔Type: Abstraction
For writing: FileInputStream , BufferedReader
BufferedReader reader = new BufferedReader(new FileReader("input.txt"));
For Reading: FileOutputStream , PrintWriter
PrintWriter writer = new PrintWriter(new FileWriter("output.txt")); - answers✔✔Java File I/O