Unformatted text preview:

Programming Languages Design Specification and Implementation G22 2210 001 Rob Strom September 14 2006 Administrative Alternative mailing address for me robstrom us ibm com Everyone should subscribe to the class mailing list http www cs nyu edu mailman listinfo g22 2110 001 fa06 Readings Remainder of chapter 3 of Gelernter and Jagannathan chapter 7 MIT Scheme documentation Gelernter textbook we will notify about availability of photocopied notes Homework due end of class 4 Scheme Convert list of atoms to concrete tree according to the simple grammar Convert concrete tree to abstract tree Review BNF Concrete and Abstract Syntax Trees e expr expr term expr term term term term factor term factor factor factor number identifier expr t t f e e t t t f f f f A B C D A B C D Use of types Operator overloading Polymorphism Conversion Implementation choices Error checking Differences What s typed The value the container or the name If the name can refer to different containers must they all be the same type Types Integer Float In COBOL Decimal Second class Hollerith Fortran Example Fortran Name Spaces Global Statically Scoped Variables Name Spaces Procedures and Functions Common Blocks One global name space One per procedure function Dynamically Scoped None Fortran Static and Runtime Naming Scope PROGRAM MAIN COMMON FOO A B I BAR C D BAZ E F J DIMENSION Z 999 CALL SWAP W Z 200 SUBROUTINE SWAP X Y COMMON FOO OLDX GORP K TEMPX X X Y Y TEMPX OLDX TEMPX FUNCTION N I COMMON BAZ X GORP L NTEMP I 2 3 I 2 N NTEMP L References Invisible but Significant EQUIVALENCE COMMON Binding Control flow Spaghetti code GOTO and assigned GOTO Can jump anywhere except To another procedure Inside a DO loop from outside the loop IF tests and jumps not blocks DO loops and jumps Everything static Dimensions of arrays although not necessarily visible to subroutines Number of instances of storage blocks All programs both static and global except statement functions All I O devices static and global What can go wrong Syntax problems DO I 1 3 Passing a constant CALL SWAP 2 3 Unchecked Bounds Uninitialized Variables Algol 60 Static and Runtime Naming Scope PROCEDURE MAIN x read BEGIN INTEGER ARRAY FOO 1 X j 20 blat j FOO j PROCEDURE blat x y BEGIN x 1000 y 1000 END INTEGER PROCEDURE random BEGIN OWN INTEGER seed random seed some new value END New features in Algol 60 Call by name Dynamic array bounds Recursive creation of local stack variables Own variables Nested declarations scopes Inner procedures Beyond Algol 68 PL I C Fully dynamic storage e g PL I s storage classes STATIC like FORTRAN local external AUTOMATIC like Algol 60 non own CONTROLLED dynamically allocated X BASED Y dynamically allocated with pointer New things that can go wrong Unbounded memory Dangling references via pointers Dangling closures


View Full Document

NYU CSCI-GA 2110 - Design, Specification, and Implementation

Loading Unlocking...
Login

Join to view Design, Specification, and Implementation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Design, Specification, and Implementation and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?