Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes, notes, notes) Dr. Carter Tiernan
Ch Ch jcmt CSE 3302 Programming Languages Block Structured Languages: Activation records Fixed program part Variable activation-record part –Instruction part –Environment part Local context Nonlocal context
Ch Ch jcmt CSE 3302 Programming Languages Nonlocal context Static link IP-EP locus of control Two coordinate access –Static distance –Offset Two step access
Ch Ch jcmt CSE 3302 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
Ch Ch jcmt CSE 3302 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
Ch Ch jcmt CSE 3302 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
Ch Ch jcmt CSE 3302 Programming Languages Blocks Handled like degenerate procedures Activation records very important in language implementation Two-coordinate addressing is also significant Concepts
Ch Ch jcmt CSE 3302 Programming Languages Ada Overview Rationale –Software complexity and cost –Maintenance and portability –Government backing History – Specifications –CII-Honeywell-Bull : Jean Ichbiah –Mil std and ANSI ‘83, ISO ‘87
Ch Ch jcmt CSE 3302 Programming Languages Ada Highlights Abstract Data Types –Information Hiding (D. L. Parnas) Verification Concurrency Generally uses Pascal as basis
Ch Ch jcmt CSE 3302 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
Ch Ch jcmt CSE 3302 Programming Languages Ada Declarations Object (constants and variables) Type Subprogram (procedures, functions and overloaded operators) Package (executable modules) Task (concurrently executable modules)
Ch Ch jcmt CSE 3302 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
Ch Ch jcmt CSE 3302 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’
Ch Ch jcmt CSE 3302 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.
Ch Ch jcmt CSE 3302 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 With
Ch Ch jcmt CSE 3302 Programming Languages Ada Packages ADT Library of routines Shared data structure Generic packages –ADT templates –Parameters Internal vs. External representations
Ch Ch jcmt CSE 3302 Programming Languages Ada: Control Structures Iterator - loop end loop –Infinite loop - uses ‘exit’ keyword or ‘exit when’ –‘while’ phrase prefix –‘for’ phrase prefix Conditional - if then end if Case Subprograms Goto Exception handling Concurrency control
Ch Ch jcmt CSE 3302 Programming Languages 4th Generation Languages Data abstraction languages Control structure for concurrency Refinement and correction of 3rd gen