06-data-types - 1 CSE 452: Programming Languages Data Types...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CSE 452: Programming Languages Data Types 2 Organization of Programming Languages-Cheng Where are we? High-level Programming Languages Logic Functional Imperative Concepts specification (syntax, semantics) variables (binding, scoping, types, ) statements (control, selection, assignment,) Implementation compilation (lexical & syntax analysis) Assembly Language Machine Language Object Oriented You are here 2 3 Organization of Programming Languages-Cheng Types: Intuitive Perspective ! Behind intuition: ! Collection of values from a domain (denotational perspective) ! Internal structure of data, described down to small set of fundamental types (structural view) ! Equivalence class of objects (implementors approach) ! Collection of well-defined operations that can be applied to objects of that type (abstraction approach) ! Utility of types: ! Implicit context ! Checking: ensure that certain meaningless operations do not occur. (type checking cant catch all). 4 Organization of Programming Languages-Cheng Terminology ! Strong typing :language prevents you from applying an operation to data on which it is not appropriate. ! Static typing : compiler can do all the checking at compile time. ! Examples: ! Common Lisp is strongly typed, but not statically typed. ! Ada is statically typed. ! Pascal is almost statically typed. ! Java is strongly typed, with a non-trivial mix of things that can be checked statically and things that have to be checked dynamically. 3 5 Organization of Programming Languages-Cheng Type System Has 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?) 6 Organization of Programming Languages-Cheng Type compatibility/equivalence ! Compatibility: indicates what you can do ! More useful concept of the two ! Erroneously used interchangeably ! Equivalence: ! What are important differences between type declarations? ! Format does not matter: struct { int a, b; } " Same as struct { struct{ int a, b; AND int a; } int b;} 4 7 Organization of Programming Languages-Cheng Equivalence: two approaches ! Two types: name and structural equivalence ! Name Equivalence : based on declarations ! More commonly used in current practice ! Strict name equivalence: " Types are equivalent if referring to same declaration ! Loose name equivalence: " Types are equivalent if they refer to same outermost constructor ! (refer to same declaration after factoring out any type aliases) ! Structural Equivalence : based on meaning/semantics behind the declarations....
View Full Document

This note was uploaded on 07/25/2008 for the course CSE 452 taught by Professor Cheng during the Fall '05 term at Michigan State University.

Page1 / 34

06-data-types - 1 CSE 452: Programming Languages Data Types...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online