190 likes | 413 Views
CSE3302 Programming Languages (notes, notes, notes). Dr. Carter Tiernan. Block Structured Languages: Activation records. Fixed program part Variable activation-record part Instruction part Environment part Local context Nonlocal context. Nonlocal context. Static link
E N D
CSE3302Programming Languages(notes, notes, notes) Dr. Carter Tiernan Programming Languages
Block Structured Languages: Activation records • Fixed program part • Variable activation-record part • Instruction part • Environment part • Local context • Nonlocal context Programming Languages
Nonlocal context • Static link • IP-EP locus of control • Two coordinate access • Static distance • Offset • Two step access Programming Languages
Procedure Activation • Needs static and dynamic links • Three steps • Save caller state • Create callee activation record • Enter callee in context of new record Procedure Deactivation • Two steps • Delete callee activation record • Restore the state of the caller Programming Languages
Procedural Parameters • Two element record • IP gives entry address of actual procedure • EP gives pointer to environment of definition of procedure • Block structured languages generally only allow procedures to be passed in - not to be returned Programming Languages
Nonlocal context • Static chains as discussed • Implemented as linked lists • Display • Random access to context • Array with pointers to activation records • Calls require saving display data • Shallow binding • Static activation records on stack Programming Languages
Blocks • Handled like degenerate procedures Concepts • Activation records very important in language implementation • Two-coordinate addressing is also significant Programming Languages
Ada Overview • Rationale • Software complexity and cost • Maintenance and portability • Government backing • History • 1975 - 79 Specifications • CII-Honeywell-Bull : Jean Ichbiah • Mil std and ANSI ‘83, ISO ‘87 Programming Languages
Ada Highlights • Abstract Data Types • Information Hiding (D. L. Parnas) • Verification • Concurrency • Generally uses Pascal as basis Programming Languages
Ada • Packages support info hiding and implement abstract data types • Specification of public names • Private body of package • Control structures include • Exception handling • Concurrent programming Programming Languages
Ada Declarations • Object (constants and variables) • Type • Subprogram (procedures, functions and overloaded operators) • Package (executable modules) • Task (concurrently executable modules) Programming Languages
Ada: Data Structures • Based on Pascal • Range constraints • Accuracy constraints: digits, delta • Discriminant constraint • Index constraint • Name equivalence • Subtype, derived type • Overloaded enumerations Programming Languages
Ada: Name structures • Variables can be initialized at declaration • Constants are declared with keyword and are constant within scope • Separation of ‘interface’ & ‘implementation’ Programming Languages
Ada Issues • “Global Variables Considered Harmful” Wulf & Shaw • Side effects • Indiscriminate access • Vulnerability • No overlapping definitions • Parnas’s principles of information hiding • One must provide the intended user with all the info needed to use the module correctly and nothing more. • One must provide the implementor with all the info needed to complete the module and nothing more. Programming Languages
Name structures (cont.) • Packages • Interface specification • “public” part of package • May have “private” section • Body • Defines everything in interface specification • This is private to the package developer • Use <package_name> • With <package_name> Programming Languages
Ada Packages • ADT • Library of routines • Shared data structure • Generic packages • ADT templates • Parameters • Internal vs. External representations Programming Languages
Ada: Control Structures • Iterator - loop <body> end loop • Infinite loop - uses ‘exit’ keyword or ‘exit when’ • ‘while’ phrase prefix • ‘for’ phrase prefix • Conditional - if <condition>then <body>end if • Case • Subprograms • Goto • Exception handling • Concurrency control Programming Languages
4th Generation Languages 4th • Data abstraction languages • Control structure for concurrency • Refinement and correction of 3rd gen Programming Languages