{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

04-binding - Naming scoping binding etc Instructor Dr B...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 1 Organization of Programming Languages-Cheng Naming, scoping, binding, etc. Instructor: Dr. B. Cheng 2 Organization of Programming Languages-Cheng Imperative Programming The central feature of imperative languages are variables Variables are abstractions for memory cells in a Von Neumann architecture computer Attributes of variables Name, Type, Address, Value, … Other important concepts Binding and Binding times Strong typing Type compatibility rules Scoping rules 3 Organization of Programming Languages-Cheng Preliminaries Name : representation for something else E.g.: identifiers, some symbols Binding : association between two things; Name and the thing that it names Scope of binding : part of (textual) program that binding is active Binding time : point at which binding created Generally: point at which any implementation decision is made.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 4 Organization of Programming Languages-Cheng Names (Identifiers) Names are not only associated with variables Also associated with labels, subprograms, formal parameters, and other program constructs Design issues for names: Maximum length? Are connector characters allowed? (“_”) Are names case sensitive? Are the special words: reserved words or keywords? 5 Organization of Programming Languages-Cheng Names Length If too short, they will not be connotative Language examples: FORTRAN I: maximum 6 COBOL: maximum 30 FORTRAN 90 and ANSI C (1989): maximum 31 Ansi C (1989): no length limitation, but only first 31 chars significant Ada and Java: no limit, and all are significant C++: no limit, but implementors often impose one Connector characters C, C++, and Perl allows “_” character in identifier names Fortran 77 allows spaces in identifier names: 㻶㼘㼐 㻲㼉 㻶㼄㼏㼄㼕㼌㼈㼖 and 㻶㼘㼐 㻲㼉㻶㼄㼏㼄㼕㼌㼈㼖 refer to the same identifier 6 Organization of Programming Languages-Cheng Names Case sensitivity C, C++, and Java names are case sensitive Disadvantages: readability (names that look alike are different) writability (must remember exact spelling) Java: predefined names are mixed case (e.g. IndexOutOfBoundsException) Earlier versions of Fortran use only uppercase letters for names (because the card punches had only uppercase letters!)
Image of page 2
3 7 Organization of Programming Languages-Cheng Names Special words Make program more readable by naming actions to be performed and to separate syntactic entities of programs A keyword is a word that is special only in certain contexts Disadvantage: poor readability e.g., Fortran: 㻵㼈㼄㼏 Integer Integer is a 㻵㼈㼄㼏 variable 㻬㼑㼗㼈㼊 㼈㼕 Real Real is an 㻬㼑㼗㼈㼊 㼈㼕 variable A reserved word is a special word that cannot be used as a user-defined name 8 Organization of Programming Languages-Cheng Variables A variable is an abstraction of a memory cell Variables can be characterized by several
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}