Overview: - PowerPoint PPT Presentation

About This Presentation
Title:

Overview:

Description:

Operations that are to be applied to certain data in a certain sequence ... Chapter 4 concentrates data, types ... leaving the operations unchecked. Typing ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 14
Provided by: dolore
Learn more at: http://www.cs.bsu.edu
Category:

less

Transcript and Presenter's Notes

Title: Overview:


1
Overview
  • Lecture 6
  • Dolores Zage

2
What is a program?
  • Operations that are to be applied to certain data
    in a certain sequence (definition holds for all
    languages)
  • Basic differences among languages exist in
  • types of data allowed
  • types of operations available
  • mechanisms for controlling the sequence of the
    operations applied to the data

3
Focus
  • Chapter 4 concentrates data, types (highlighting
    imperative languages)
  • Chapter 5 procedures (extensions to the usual
    built in types defined by the programmer)
    encapsulation (a higher level abstraction or
    representation) actually defining the syntax and
    operations on this construct!

4
Type Checking
  • Computer hardware data storage representations
    usually include no type information
  • 1110000101010.111
  • Can you tell if this is an integer, real,
    sequence of chars, an instruction?
  • Common error in assembly languages is to invoke
    an operation such as integer addition on
    arguments of the wrong type

5
Type Checking
  • These errors are difficult to locate because the
    operation works since the result (usually
    meaningless) is just a bit string.
  • A major advantage of using a higher level
    language is that the language implementation can
    provide type checking.
  • Type checking means that each operation executed
    by a program receives the proper number of
    arguments of the proper data type

6
Dynamic type checking
  • At run time
  • done immediately before operation
  • usually implemented by storing a type tag in each
    data object
  • each operation must attach the appropriate type
    tags to the results
  • done in languages that do not require
    declarations
  • dynamic types advantage is flexibility in design
    - programmer is freed from most concerns about
    data types

7
Disadvantages of Dynamic Type Checking
  • Errors lurk in the program until they are
    executed (in large programs can be several hours
    of execution)
  • not all program paths are executed
  • type information can be substantial
  • implemented in software and each operation must
    be checked before -gt speed of execution is likely
    to be greatly reduced

8
Static Type Checking
  • Eliminate or minimize dynamic checking-gt perform
    type checking at compile time.
  • Collect info in symbol table
  • In most languages, static type checking is not
    possible for some constructs
  • dynamic type checking
  • leaving the operations unchecked

9
Typing
  • Strong - all type errors can be detected
    statically (strongly typed)
  • Text book definition - so only one language can
    fit in this category - ML
  • Notice that when a language has either arrays,
    enumeration, subranges -gt it cannot be strong
  • How do you know that A1number will be in the
    range of your array?
  • or that Monday Sunday will still be part of the
    enumerated set?

10
Typing
  • So the question is what will you give up to get a
    strongly typed language !(or to get a safe
    run-time program)
  • Another question you may have How does a
    strongly typed language do any operations? Every
    overflow condition is defined in the language.
  • There is much confusion on strong typing. You
    either catch ALL errors or you are weak. PERIOD.
    But I guess there are scales of weakness..
  • So there is much confusion out in the PUBLIC.
    And there is a difference between strong type
    and structured type!

11
Typing
  • what-is definition
  • by what-is.com
  • what is a Merry Strongly-Typed Christmas
  • Garbage Collection for Strongly-Typed Languages
  • typing and binding,
  • page by Carl Erickson
  • PERL
  • for slow connections, I simply downloaded the
    page and made a local copy

12
Other PL sites
  • Hotprog.com

13
Weak - Safe
All Programs
Weak
Safe
There are weak programs that are safe (type
errors are caught at run time)
Write a Comment
User Comments (0)
About PowerShow.com