Sequence Control PL/I case statement examples: In most languages, flow is linearly downward /* Example 1 */ statement by statement. We have SELECT (TRANSACTION.COMMAND); WHEN ('DEPOSIT') CALL DEPOSIT(TRANSACTION, statements which can alter that flow: ACCOUNT); Conditional - if, if-then-else, case WHEN ('WITHDRAWAL') CALL constructs WITHDRAWAL(TRANSACTION, ACCOUNT); WHEN ('INTEREST') CALL Iteration - loop, repetition (e.g., for) ADD_INTEREST(TRANSACTION, ACCOUNT); Subprogram - macros, functions, OTHERWISE recursion, parallel, event-based DO; Interrupts - an unusual event altering PUT SKIP EDIT('INVALID COMMAND: ', TRANSACTION.COMMAND) flow (A, A); END; END; /* Example 2 */ SELECT; WHEN (TRANSACTION.COMMAND = 'WITHDRAWAL' & ACCOUNT.BALANCE < 0) CALL OVERDRAWN(TRANSACTION, ACCOUNT); WHEN (TRANSACTION.COMMAND = 'DEPOSIT') CALL DEPOSIT(TRANSACTION, ACCOUNT); OTHERWISE CALL WITHDRAWAL(TRANSACTION, ACCOUNT); END; Binding Execution Time The when a program element is bound binding of variables to values to a characteristic or property strongly binding of variables to their locations (e.g., influences a programming language. automatics in C) binding of parameters to arguments Categories of Binding Times - during program on function entry for and Execution Time by value by execution address parameters Translation Time (compile time) - on reference for by name parameters bindings performed by the Translation Time compiler binding of variables to their data types (C) Language Definition Time - when the binding of variables to their structure (C) language was described binding of variables to their locations (static Language Implementation Time - in C, but the actual address is bound by the variations for a particular loader) implementation of the Language Definition Time language meaning of +, -, *, / meaning of if, printf Language Implementation Time ordering of bits (little endian, big endian) size of int, size of long meaning of isalpha in C Object Orientation // C typedef for Student
Sequence Control In most languages, flow is linearly downward statement by statement. We have statements which can alter that flow: Conditional - if, if-then-else, case constructs Iteration - loop, repetition (e.g., for) Subprogram - macros, functions, recursion, parallel, event-based Interrupts - an unusual event altering flow PL/I case statement examples: /* Example 1 */ SELECT (TRANSACTION.COMMAND); WHEN ('DEPOSIT') CALL DEPOSIT(TRANSACTION, ACCOUNT); WHEN ('WITHDRAWAL') CALL WITHDRAWAL(TRANSACTION, ACCOUNT); WHEN ('INTEREST') CALL ADD_INTEREST(TRANSACTION, ACCOUNT); OTHERWISE DO; PUT SKIP EDIT('INVALID COMMAND: ', TRANSACTION.COMMAND) (A, A); END; END; /* Example 2 */ SELECT; WHEN (TRANSACTION.COMMAND = 'WITHDRAWAL' & ACCOUNT.BALANCE < 0) CALL OVERDRAWN(TRANSACTION, ACCOUNT); WHEN (TRANSACTION.COMMAND = 'DEPOSIT') CALL DEPOSIT(TRANSACTION, ACCOUNT); OTHERWISE CALL WITHDRAWAL(TRANSACTION, ACCOUNT); END; Binding The when a program element is bound to a characteristic or property strongly influences a programming language. Categories of Binding Times Execution Time - during program execution Translation Time (compile time) - bindings performed by the compiler Language Definition Time - when the language was described Language Implementation Time - variations for a particular implementation of the language Execution Time binding of variables to values binding of variables to their locations (e.g., automatics in C) binding of parameters to arguments on function entry for by value and by address parameters on reference for by name parameters Translation Time binding of variables to their data types (C) binding of variables to their structure (C) binding of variables to their locations (static in C, but the actual address is bound by the loader) Language Definition Time meaning of +, -, *, / meaning of if, printf Language Implementation Time ordering of bits (little endian, big endian) size of int, size of long meaning of isalpha in C Object Orientation // C typedef for Student
cs3723OverviewWO.docx