CSE 3302CSE@UTA - PowerPoint PPT Presentation

About This Presentation
Title:

CSE 3302CSE@UTA

Description:

Close as possible to standard mathematical notation and readable ... Baroque. CSE 3302 CSE_at_UTA. Programming Languages. Ch. 3 & 4 21 jcmt. Algol: Syntactic Structures ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 27
Provided by: jcartermat
Learn more at: https://ranger.uta.edu
Category:
Tags: 3302cse | cse | uta | barque

less

Transcript and Presenter's Notes

Title: CSE 3302CSE@UTA


1
CSE3302Programming Languages(notes continued)
  • Dr. Carter Tiernan

2
Generality and HierarchyAlgol-60
  • Close as possible to standard mathematical
    notation and readable
  • Usable for describing computing processes
  • Mechanically translatable to machine language

3
Algol Design
  • Hierarchical structure / Nesting
  • (unlike C C)
  • Declarative and Imperative constructs
  • Variable, procedure, and switch
  • Computational and control-flow
  • Compilation handled differently than Fortran
  • Stack for run-time structures

4
Algol Name Structures
  • Names are NOT statically bound
  • Block structure supports scoping
  • Blocks are compound statements
    with declarations
  • Scope - contour diagrams
  • Context
  • Inner blocks implicitly inherit access to
    variables in its immediately surrounding block

5
Algol Blocks
  • Allows shared data to be easily organized with
    the subprograms that need it (but does allow
    indiscriminate access)
  • Scoping choices
  • Static called in the environment of its
    definition (used exclusively in Algol)
  • Dynamic called in the environment of its caller

6
Dynamic Scoping
  • Called in environment of caller
  • Can write general procedures that make use of
    variables and procedures supplied by callers
    environment
  • Vulnerable to being called from an environment
    without correct supporting procedures
  • Not generally used in current languages

7
Static Scoping
  • Called in the environment of its definition
  • Requires the user to pass parameters of local
    environment
  • Cannot behave differently based on call location
    only
  • Ensures that the static structure of the program
    more closely agrees with the dynamic behavior of
    the program.

8
Algol Stacks for management
  • Disjoint blocks allow conservation of memory on
    the stack
  • Assumption a variable is retained only so long
    as the program is executing in the scope of that
    variable or in a block that will return to the
    scope of that variable
  • Blocks follow LIFO execution ergo, a
    stack handles the activation records in
    a LIFO fashion

9
Responsible Design
  • Understand the programmers problem
  • Provide a high quality solution
  • Which is not necessarily the solution the
    programmers (or users) asked for
  • Responsible Design Principle
  • Caveat If the user wants it and you dont
    supply it (in their fashion), they may not accept
    your alternate (even if better) solution

10
Algol Data Structures
  • Primitives are scalars
  • Boolean, integer, and real
  • No double precision because its machine
    dependent
  • No complex due to tradeoffs of usefulness vs.
    complexity
  • Limited string type that required procedures
    coded in some other language in order to be
    output or used

11
Zero-One-Infinity Principle
  • Supports regularity - easier to learn, remember,
    and master
  • Eliminates arbitrary numerical limits
  • Applies to arrays in
  • Number of dimensions
  • Start and end values for indices

12
Algol Arrays
  • Generalized
  • Dynamic due to stack allocation

Data Types
  • Strong typing
  • Coercions and conversions
  • Type system as safety feature

13
Algol Control structures
  • Primitives
  • Assignment
  • No input/output - handled with library routines
  • Structures
  • Regularize the FORTRAN structures
  • if condition then statement1 else statement2
  • for initialization keyword test do statement

14
Algol Control and nesting
  • All control structures can handle arbitrary
    number of bracketed statements
  • Compound statements formed with begin and end
  • Algol structuring led to Dijkstras letter, GOTO
    Considered Harmful

15
Algol More control
  • Hierarchical structure
  • Structured programming
  • Recursion supported
  • Instantiation of locals
  • Every call creates a new activation record
  • Conditional expression

16
Algol Parameter passing
  • Passing by value
  • Local copy of parameter
  • Requires keyword value
  • Pass by name
  • Default mode
  • Based on substitution - Copy Rule
  • Not actually substituted for formal params

17
Algol Pass by name
  • Compare to pass by reference
  • Name parameters bound to string
  • Jensens device
  • Use pass by name with index variable to cycle
    through array elements
  • Implementation - thunk
  • Compile parameter
  • Pass address of compiled parameter code
  • Inconsistent behavior

18
Language Design Issues
  • GO TO controversy
  • Conceptual models
  • System image
  • Feature interaction

19
Algol Control (more)
  • Out of block GO TOs
  • Levels of activation must be popped
  • For-loop
  • For-list-elements reevaluated every pass
  • Step, until
  • While
  • Enumerated list
  • All of the above
  • Baroque

20
Algol Control etal.
  • Switch declaration
  • Array of statement labels
  • Processes cases - not necessarily distinct
  • Best use recombines after cases
  • Difficult to correlate with dynamic structure
  • Baroque

21
Algol Syntactic Structures
  • Machine independent / portable
  • Free-format
  • Programmers had to think about how it should look
  • Reflect the structure of the program
  • Independent of character sets
  • Reference language
  • Publication language
  • Hardware representation

22
Algol Lexics
  • Lexical conventions
  • Reserved words
  • Keywords (Algol approach)
  • Keywords in context
  • Dangling else
  • Style

23
Backus-Naur Form (BNF)
  • Precise programming language descriptions
  • English difficult to read
  • Examples incomplete
  • Perceptual clarity with precision
  • Backus - syntactic categories
  • Naur added improvements to notation
  • Metalanguage

24
BNF
  • Terminals
  • Nonterminals
  • Defined in terms of nonterminals and terminals
  • Recursive definition allowed
  • Related to Chomsky language hierarchy
  • Context-free grammar
  • Regular (non-recursive) grammar

25
Design Criteria
  • Efficiency - scientific issues
  • Minimize resources
  • Maximize safety
  • Economy - social issues
  • Maximize social benefit
  • Minimize cost
  • Elegance - aesthetic issues
  • Function follows form
  • Manifest interactions

26
Second Generation Languages
  • Elaborations and generalizations of first
    generation languages
  • Stronger typing
  • Hierarchical structure
  • Blocks
  • Control flow
  • Recursion
  • Parameter passing modes
  • Free-format syntax
  • Machine independent conventions
  • Reserved word/ Keywords

2nd
Write a Comment
User Comments (0)
About PowerShow.com