3 Pages

Lecture08

Course: CS 2130, Fall 2009
School: East Los Angeles College
Rating:
 
 
 
 
 

Word Count: 5589

Document Preview

Programming CS2130 Language Concepts Unit 8 -- Programming Language Concepts Names A name is a string of characters used to identify some entity in a program (such as a variable, type, subprogram etc.) Names are often referred to as identifiers. A number of issues arise: What is the maximum length of a name? Are names case sensitive? Can connector symbols such as underscore be used in names? Do some character...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> East Los Angeles College >> CS 2130

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Programming CS2130 Language Concepts Unit 8 -- Programming Language Concepts Names A name is a string of characters used to identify some entity in a program (such as a variable, type, subprogram etc.) Names are often referred to as identifiers. A number of issues arise: What is the maximum length of a name? Are names case sensitive? Can connector symbols such as underscore be used in names? Do some character strings have a special meaning as reserved words or keywords of the language? Early programming languages allowed only single character names, other languages place limits on maximum name length (6 in FORTRAN 77, 31 in C and FORTRAN 90) while in others, for example Java and Ada, there is no limit. A design consideration is that the limit on name length (if any) should be sufficiently large so that in practice the programmer's choice of meaningful names is not restricted. In some languages, notably C, C++ and Java, names are case sensitive, thus count, Count and COUNT all count as different names whereas others (notably Ada) are not case sensitive. There is no universal agreement as to which system is preferable. Certainly use of names differing only in the case of one or two letters reduces program readability (by other programmers) and may lead to obscure bugs if the programmer mistypes a name. Whether a language is case sensitive or not, a judicious use of case in long names can improve program readability, for example TotalSoFar or totalSoFar is generally regarded as preferable to totalsofar. The precise rules for valid names differ from language to language but generally names consist of letters and digits and must start with a letter (so that it is easy to distinguish between names and number literals). Often underscores are allowed in names; they can be useful in improving the readability of multi-word names, for example total_so_far is generally regarded as preferable to totalsofar. The counter argument is that an underscore looks too much like an operator and so if overused can reduce program readability. Also it is often mistyped as a minus sign, which can lead to obscure bugs if the component words in a name are also valid names of program variables. Some languages notably Ada only permit underscore as a separator of other characters in a name (thus a name may not start or end with an underscore nor contain consecutive underscores). Other languages allow names to begin or end with an underscore, generally as a matter of style such names should be avoided as there is no argument regarding readability here. In some languages other symbols such as $ are allowed in names, often they denote that the name has some special 'system' meaning (e.g. string variables in Basic). Keywords & Reserved Words In almost all languages there are special words such as while, if etc. that have a special meaning in the language and mark the various parts of program control structures. Such a word is referred to as a reserved word if it cannot be used as the name of a normal program entity whereas it is referred to as a keyword if it has a special meaning only in certain contexts and can be used as a name in other contexts. It is now fairly generally accepted that reserved words are preferable as a design choice compared with keywords as the latter can A Barnes, 2006 1 CS2130/Lect8 lead to readability problems. For example in FORTRAN one could write declarations such as INTEGER REAL REAL INTEGER The first defines a variable with the name REAL to be of type INTEGER (a keyword in FORTRAN) whilst the second defines a variable with the name INTEGER to be of type REAL (also a keyword); all very confusing. In some languages certain names though not reserved or keywords are always defined in the standard language environment (for example the types Integer, Character and Boolean in Ada). Although they may be redefined by the programmer, such practices are best avoided as they normally lead to severe readability problems. Other names such as the names of procedures and functions in standard libraries are also predefined. Examples are the subprogram names such as Put and Get in the Ada package Ada.Text_IO and the functions in the Standard C I/O library such as fgetc, fputc, printf and scanf etc. These are available in any program that 'imports' the standard libraries. In case-sensitive languages predefined, reserved or keywords must, of course, be spelt with the correct case (lower case in C, C++ and Java). Even in languages which are not casesensitive, programmers often adopt case conventions for typing reserved or predefined names as these are thought to improve program readability. A common but by no means universal convention is that keywords are typed in uppercase. Exercise Find out (by consulting a suitable Java textbook or on-line manual) whether type names such int, byte, char etc. are reserved words, keywords or predefined names in Java (and in C/C++). Commands and Expressions An expression is anything that can be evaluated to produce a value. An expression may contain sub-expressions which may be split up into further sub-expressions and so on. Parentheses often show the division of an expression into sub-expressions where this is not uniquely specified by operator precedence. Literals The simplest expressions are literals which directly denote values of some type: 3.14159 0 'A' "The answer is " Variables The next simplest form of expression is a variable name); the value of the expression is the current value of that variable. Function and Operator Calls A function call applies a function to its arguments yielding a result. An operator call is, in principle, no different from a function call. Infix operators such as +, , *, / etc. are simply more readable designations of certain functions, for example in Ada: "+"(3, 4) is equivalent to 3 + 4 Operators may be applied to literals, variables and other expressions to build up complex expressions. Most operators are either binary infix (such as +, , *, /, >, <, =, &&, ||, AND, A Barnes, 2006 2 CS2130/Lect8 OR etc.) with the operator symbol written in between the two operands or unary prefix (such as +, , !, NOT, etc.) with the operator preceding the single operand. Note that (in some languages such as Ada and Java) there are no literals for negative numbers rather terms such as 2 or 3.1 are expressions made up of the unary prefix operator applied to the literals 2 and 3.1 respectively. Occasionally languages permit unary postfix operators and/or ternary operators. For example in C, C++ and Java the auto-increment and auto-decrement operators can be used a unary prefix or postfix operators. ++a a++ prefix (value is value of a after increment) postfix (value is value of a before increment) The conditional operator ? : in C, C++ and Java is ternary; for example tax = (income > threshold)? (income - threshold)* taxrate : 0; This sets tax to zero if income is less than or equal to the threshold , otherwise it sets it to 23% of the income in excess of the threshold (assuming taxrate==0.23). Precedence of Operators Where two or more binary operators occur in an expression there is a potential ambiguity unless parentheses are used to specify which operators should be applied first. For example is 4*5+3 interpreted as (4*5)+3 = 23 or as 4 *(5+3) = 60 and is 1032 interpreted as (10 3)2 = 5 or as 10(32) = 9? To resolves such ambiguities operators are assigned a precedence level (or priority level) and, in the absence of bracket,) an operator with a higher precedence is applied before one with a lower precedence. In most (all?) languages the multiplicative operators (* and /) have a higher precedence than additive ones (+ and ). Thus 4*5+3 is interpreted as (4*5)+3 = 23. Where two operators are of equal precedence it is usual to evaluate the leftmost one first (left associativity). Thus 1032 is interpreted as (103)2 = 5. However left associativity is by no means universal. When using the exponentiation operator in Ada we must explicitly specify the order of evaluation by using brackets; for example A**B**C is illegal we must write either A**(B**C) or (A**B)**C to explicitly specify which of the two (different) meanings is intended. Also we will see below example of operators which associate to the right (for example the assignment operators =, += etc. in C and Java). Generally comparison operators and Boolean operators have a lower precedence than arithmetic ones and usually comparison operators have a higher precedence than Boolean ones. Thus for example we can write X>Y AND Z>0 without brackets in Ada and similarly x>y && z>0 in C and Java. However in Modula-2 comparison operators have a lower precedence than Boolean ones so that it is necessary to write (X>Y) AND (Z>0). In most languages logical AND has a higher precedence than OR. Thus in C and Java the expression a || b && c is interpreted as a || (b && c) and brackets must be used if || is to be evaluated first, i.e. (a || b) && c. Ada is somewhat of an exception as AND and OR have the same precedence and brackets must be used to make the order of evaluation clear. Thus A OR B AND C would cause an compilation error; one must write either A OR (B AND C) or (A OR B) AND C to explicitly specify which of the two (different) meanings is intended. When translating complex expressions involving many operators from one language to another one needs to be aware that the precedence rules may differ from one language to the A Barnes, 2006 3 CS2130/Lect8 next and so the meaning of an expression may be different in the two languages; consult the precedence rules for the languages concerned to see whether it is necessary to add extra parentheses to preserve the meaning of an expression when translating code from one language to another. When writing new code involving complex expressions, it is a good idea to use extra brackets to make the intended order of evaluation explicit rather than relying on (perhaps obscure) precedence rules of the particular language. This avoids 'nasty surprises' and makes code easier to read and maintain. Of course the insertion of redundant bracket pairs should not be overdone as this too reduces readability of the code. Aggregates An aggregate yields a value of a composite type and can be regarded as literals for composite types. Aggregates can be used to initialize composite data structures such as arrays and records (structures in C). For example in Java storage for an array object can be allocated and initialised using an array aggregate. For example int[] a = {5, 2, 1, 4}; which is equivalent to the sequence int[] a = new int[4]; a[0] = 5; a[1] = 2; a[2] = 1; a[3] = 4; Note however that array aggregates can only be used when an array variable is declared, they cannot be used to (re-)initialise arrays that have already be created. Thus the following are illegal int a = new int[4] = {1, 2, 3, 4}; // !!?? illegal in Java or a = {4, 5, 6, 7}; // !!?? illegal in Java To achieve the intended effect of the last statement we have no alternative but to assign to each array element separately: a[0] = 4; a[1] = 5; a[2] = 6; a[3] = 7; In Ada the component values of aggregates may be any expression of the appropriate type and aggregates can be used to reinitialize compound data structures. Other languages have more restrictive rules; for example in Pascal the values in aggregates must be literals. In Java, C and C++ the values must also be literals and furthermore as we have seen aggregates may only be used to initialise arrays and structures (records) when they are declared; they may not be used to assign values in normal assignments. Commands The state of a computation at a particular time comprises an internal state which includes the current values of all extant1 variables and an indication the next instruction2 to be executed and an external state which includes the state of all its input and output streams. Imperative languages support explicit modification of the program state by the execution of commands. Commands include assignment, input and output operations3, selections (if and switch etc.), repetitions (while, for etc.) and procedure or method call steps. Modification of program state may be direct via assignment to program variables or 1 2 extant = currently existing (more or less) or in parallel programs with multiple threads of execution the next instruction to be executed in each thread. 3 In some languages such as Pascal I/O operations are built-in whereas in others C, C++, Ada, and Java I/O is provided by the provision of 'standard' library procedures. A Barnes, 2006 4 CS2130/Lect8 execution of I/O commands or indirect through control constructs and procedure calls which invoke other commands. Some languages, notably functional languages (such as Haskell and Miranda) and to a certain extent Lisp, are based entirely on function evaluation and have no constructs that modify program state, that is they have no commands. Instead computation is organised by combining functions through functional composition (function of a function) and by higher order functions which can (for example) apply a function to an arbitrary list. Compound Commands Although only if and while compound commands together with sequencing are sufficient to express any algorithm, most languages provide additional selection and repetition commands for increased convenience and enhance clarity when expressing certain common constructs (for for loops controlled by a count, switch for multi-way selections based on a single value). One major issue is how the end of the commands comprising the body of the compound command is determined. There are three approaches commonly used in the major programming languages. The body of a compound command is syntactically a single command. If the body is to contain more than one command then these commands must enclosed in a block or grouping construct. The end of the body of a compound command is marked by a special keyword typically END The extent of the body of a compound command is marked by indenting the body relative to reserved or key word(s) defining the command. The first approach is exemplified by C, C++, Java, Pascal and RLisp. Thus we have C, C++, Java if (condition) command; else command; while (condition) command; If necessary in C, C++ or Java multiple commands can be grouped as a single command by enclosing them in a block {...}. if (condition) { commands } else { commands } while (condition) { commands } In Pascal commands are grouped by enclosing them between BEGIN ... END;. In RLisp commands can be grouped by enclosing in a group statement <<...>>. Ada, Algol and Modula-2 exemplify the second approach. The parts of a compound command are delimited by keywords such as THEN, ELSE and END and multiple commands can be inserted between these keywords. Ada IF condition THEN commands; ELSE commands; END IF; WHILE condition LOOP commands; END LOOP; A Barnes, 2006 5 CS2130/Lect8 Some languages (e.g. Algol) use keywords spelt backwards fi, esac etc. to terminate the corresponding compound command whereas others notably Ada use END followed by a keyword identifying the type of compound command (END IF, END LOOP, END CASE etc.). Modula-2 on the other hand marks the end of all compound commands with a simple END. The first two approaches are superior as they allow the language compiler to perform better error detection/diagnostics, for example in Modula-2 and Ada Modula-2 MODULE P; variable declarations BEGIN WHILE condition DO commands IF condition THEN commands commands END commands END. Ada PROCEDURE P IS variable declarations BEGIN WHILE condition LOOP commands IF condition THEN commands commands END LOOP; commands END P; Here the user has accidentally omitted the END keyword for the IF statement; the Modula-2 compiler cannot detect an error until the end of the module is reached as it interprets the END that is intended to terminate the WHILE as the end of the IF whereas in Ada the error is detected at the END LOOP line as END IF is expected. Note similar problems arise with providing good diagnostics in the C family of languages if a closing brace } is accidentally omitted. public static void main(String[] args) { variable declarations while (condition) { commands if (condition) { commands // missing } to close if commands } commands } // compiler only detects error here The third approach is exemplified by the scripting language Python (and also the parallel processing language occam) where indentation delimits the extent of compound commands. In such a language correct indentation is obviously essential4. x = 10 while x > 0: if x == 3: print 'ignition', else: print x, x = x-1 print 'lift-off', # last line of if # last line of while Of course it is good programming style in any language to emphasize the logical structure by use of indentation as this improves program readability and aids debugging by providing visual cues to the human reader. 4 Hence it is important to use a fixed width font when printing a in program such a language so that indentation is correctly displayed. A Barnes, 2006 6 CS2130/Lect8 The Dangling else The first approach has a pitfall for the unwary; consider the following Java code which is intended to output either the message "Positive" or "Negative" depending on the sign of the variable x (whereas if x is zero no message should be output): if (x >= 0) if (x > 0) System.out.println("Positive"); else System.out.println("Negative"); In fact the message "Negative" is output only when x is zero and nothing is output when x is negative. The problem is that in the C family of languages the syntax is potentially ambiguous: it is not clear whether the else part should belong to the first or second if command. The ambiguity is resolved in C, C+= and Java by (rather arbitrarily) decreeing that the else part belongs to the nearest if command. Hence the indentation that reflects the actual meaning is if (x >= 0) if (x > 0) System.out.println("Positive"); else System.out.println("Negative"); Note that the ambiguity is nothing to do with the fact we have omitted curly brackets around the alternative commands in the selection, the following fragment has exactly the same meaning as the one above: if (x >= 0) if (x > 0) { System.out.println("Positive"); } else { System.out.println("Negative"); } To get the meaning implied by the indentation we must enclose the nested if in an extra block (the closing brace then serves to terminate the inner if): if (x >= 0) { if (x > 0) System.out.println("Positive"); } else { System.out.println("Negative"); The problem of the 'dangling else' also occurs in C, C++ and Pascal and indeed any language adopting the first approach to delimiting the extent of compound commands. It cannot occur in languages such as Ada, which have an explicit keyword to terminate compound commands as the positioning of the END IFs specifies which IF the ELSE belongs to. IF x >= 0 THEN IF x > 0 THEN Put_Line("Positive"); END IF; ELSE Put_Line("Negative"); END IF; IF x >= 0 THEN IF x > 0 THEN Put_Line("Positive"); ELSE Put_Line("Zero"); END IF; END IF; Neither can the dangling else occur in languages such as Python and occam where indentation is significant and serves to indicate the extent of compound steps. A Barnes, 2006 7 CS2130/Lect8 Multi-way selections A simple if command allows for two-way selections and one way selections (depending on whether there is an else part or not). Some languages, such as Ada, allow a single IF command to be used for multi-way selections by allowing zero or more ELSIF (or in some languages elif) parts; the IF command is terminated by a single END. Other languages only permit such multi-way selections by using nesting IF 's (with the need to terminate each IF with a corresponding END IF should the language require it or with the danger of potential ambiguity if there is no explicit terminator as in C and Java). Note also the Lisp COND command is equivalent to an IF with (optional) ELSIF and ELSE parts: (COND ((condition1 commands1) (condition2 commands2) (condition3 commands3) ........ (T commandsN)) ) IF condition1 THEN commands1 ELSIF condition2 THEN commands2 ELSIF condition3 THEN commands3 ........ ELSE commandsN END IF; In C or Java, if we follow the convention of always enclosing the else parts of if commands in braces, we would need a plethora of closing braces (this is obvoisly error prone: if (condition1) { commands1 } else { if (condition2) { commands2} else { if (condition3) {commands3} else { if (condition4) {commands4} else { commands5} } } } } For this reason the usual C and Java style convention is usually broken by omitting brackets after the elses and aligning all the elses: if (condition1) { commands1 } else if (condition2) { commands2} else if (condition3) {commands3} else if (condition4) {commands4} else { commands5} CASE or switch Most languages provide a construct for multi-way selections based on the value of a single expression. For example let month and season be two suitable enumeration types: C, C++, Java enum enum enum enum Month {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec}; Season {Winter, Spring, Summer, Autumn}; Month month; Season season; Ada TYPE MonthType IS (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); TYPE SeasonType IS (Winter, Spring, Summer, Autumn); month : MonthType; season SeasonType; A Barnes, 2006 8 CS2130/Lect8 then we can write C, C++, Java switch (month) { case Dec: case Jan: season = winter; case Mar: case Apr: season = spring; case Jun: case Jul: season = Summer; case Sep: case Oct: season = Autumn; } case Feb: break; case May: break; case Aug: break; case Nov: break; Ada CASE month IS WHEN Dec|Jan|Feb => season := Winter; WHEN Mar .. May => season := Spring; WHEN Jun .. Aug => season := Summer; WHEN Sep .. Nov => season := Autumn; END CASE; Several issues arise: What types are allowed for the governing expression? Does control fall through from one alternative to the next unless explicitly prevented? Can a default action be provided? Must the governing expression match one of the alternatives (if a default is not provided)? Generally most languages restrict the type of the governing expression to be discrete (of an integer, character or enumeration type). However a few scripting languages permit more general types (strings, real values etc.) in a similar fashion to allowing more general types to be used as array subscripts. Generally an explicit alternative can only appear once in the case or switch command; to allow an alternative to appear more than once would result in nondeterministic program behaviour. In some languages, notably C, C++ and Java, control falls through from one case clause to the next unless the switch command is explicitly exited with a break command. Although this can be a useful trick occasionally, it can lead to maintenance problems if a later programmer inserts extra alternatives in the switch statement between the original two alternatives. For this reason and on the grounds of frequency, in most modern languages (including Ada) at most one case alternative is executed and control then passes to the end of the CASE. We note in passing that Ada provides an number of ways of specifying the alternatives namely single alternatives, several alternatives separated by "|" or a range of alternatives specified with "..". In the C family of languages only single alternatives are allowed although the effect of a list of alternatives can be achieved by supplying no code corresponding to some alternatives and falling through to the next case (as in the example above); this is probably the only case where use of 'fall-through' can be recommended. Most languages allow a default (catch-all) part of a case or switch statement. This is executed if the value of the governing expression does not match any of the supplied alternatives. For obvious reasons this must be placed after all explicit alternatives and so use of break is superfluous in this case). C, C++, Java default: commands Ada WHEN OTHERS => commands In Ada all possible values of the governing expression must appear explicitly in the list of alternatives or there must be a catch-all WHEN OTHERS => alternative otherwise a compilation error occurs. In many other languages (including C and Java) if a particular A Barnes, 2006 9 CS2130/Lect8 alternative does not appear and if there is no default alternative then control simply passes to the end of a case or switch command. Repetitions Virtually all imperative languages provide a pre-conditioned while loop for indefinite repetitions. The commands in the loop body are repeated until the controlling condition becomes false and if the controlling condition is initially false the loop commands are not executed at all. Some languages also provide a post-conditioned loop in which the controlling condition is evaluated at the end of the loop so that the loop body is always executed at least once. C, C++, Java do { commands while (condition); Pascal REPEAT commands UNTIL condition; Note that in the former case the loop continues whilst the controlling condition is true, but in the latter it continues until controlling condition is true. Pre-determined Repetitions Most imperative languages provide a for loop to control iterations where the number of repetitions is known in advance. Several issues arise: What types are allowed for the controlling loop variable? Is the loop variable local to the loop or is it declared normally and so obeys normal scope rules? If the latter what is its final value? Can the loop variable be altered explicitly? Is the final bound for the loop variable evaluated once before the loop starts or before each loop iteration? Are reverse loops supported and are increments/decrements other than unity supported? Generally real values are not recommended in for loops even if the language permits it (as in C and Java) due to the problem of rounding errors; the loop might be executed one more time or one fewer time than expected; for example for (float x = 0.0; x <= 10.0; x += 1.0/3.0) { commands } As 1/3 cannot be represented exactly in binary or denary, the loop might only be executed 30 times rather than the expected 31 times. Similarly if <= were replaced by < the loop might be executed 31 times rather than the expected 30 times. In Ada the loop variable can be of any discrete type (integer type, modular type, character type or an enumeration type) whereas in some languages only integer types are allowed. In Ada, the loop variable is declared implicitly by the FOR command and its type is deduced from the type of the supplied limit values. In Ada the loop variable cannot be altered explicitly in the loop body and its scope is local to the loop body. In some languages (including the C family) a more permissive approach is adopted. The loop variable may be declared in the normal way and obeys normal scope rules. The loop variable can also be altered explicitly in the loop body. Although this is undoubtedly very ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

CSU Fullerton - OPS - 535
1OPS535Advanced TCP/IP Network AdministrationRPC and NFSRaymond Chan Seneca College of Applied Technology2What is RPC?RPC is a programming paradigm (or protocol) Based on work at Xerox PARC in the early 1980s RPC use XDR encoding Used by
CSU Fullerton - OPS - 535
Professor: RaymondChan Email: raymond.chan@senecac.on.caUseemailforallcommunication.Pleaseuse propergrammarandspelling.OnlyemailsfromyourSenecaLearn accountswillbereplied.PleaseaddOPS535asaprefixtothesubject line. Webpage: Myhomepageisathttp:/cs.sene
Air Force Academy - ME - 324
Granta Design, February 2007 Granta Design, February 2007Getting started with CES EduPackThese exercises give an easy way to learn to use the CES EduPack software. The comprehensive Help file and CES InDepth within the software give more detail
Air Force Academy - ME - 492
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
7#4a#&quot;#A#0#0#1#1#1#1#X#23#23#23#2C# #2S#2o#2o#3a#x#23#3# #3#47#*#4a#1#47#4#&amp;#47#47#4a#47#47#47#47# #47##47#Answer 3 questions.Time allowed: 1.5 hoursDisclaimer:This sample paper gives an indication as to the style of the sort of questions that may ap
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 229
2009WeekJan. 5 Jan. 9Introduction to Engineering DesignMonday Lab.1B71 2:30-5:20PM Class start Jan 5 Introduction of Faculty and Group Members Introduction to the Design Projects. Prof. Burton Design Process &amp; Designers- Prof. W.Szyszkowski (Co
East Los Angeles College - CS - 2130
CS2130 Programming Language ConceptsUnit 15 addendum Function Pointers in C and C+We can also define function pointers in C or C+. For example to define a pointer type to refer to functions of type double &gt; double we would define#include &lt;math.h&gt;
CSU Fullerton - SRT - 0901
SRT210Week OneWeek OverviewCourse Introduction System Administrators' Role Security Policy Role Types of Security Policies Week One TasksYour ProfessorRaymond Chan Email: raymond.chan@senecac.on.ca Home page: cs.senecac.on.ca/~rchan/ Office
East Los Angeles College - CS - 2130
There is no lab sheet for the labs in the weeks ending Fri 24thFebruary and Friday 3rd March.This is to allow students to work on the PLC coursework assignmentwhich is due in 7th March.There will be a lab sheets for the labs in week 8-11 ( wee
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLab Class 4 An On-screen Time Display Program In this example a task is used to manage a clock which displays the time and date at a certain position on the screen; every second the task updates the
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 11 More on Synchronisation in Concurrent Ada Programs The Ada Rendezvous Protected objects and protected types largely solve the problem of synchronising task access to shared data structures. P
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 16 - More on Object-Oriented Programming in Ada Object-Oriented Features in Standard Ada Libraries The standard Ada libraries use the object-oriented features of Ada to provide a number of power
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 13 Encapsulation and Abstraction Client/Server Model A package typically provides a service that is utilised by a client. The interface of a package should provide exactly the information needed
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 8 General Access Types In CS1210 (DSA) access or pointer types were used to provide a means of manipulating objects created by an allocator (i.e. NEW). Such access types are referred to as pool-
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 4 - Bindings and Scope Binding Each time execution of a program in a high-level programming language such as Ada reaches a declaration that declaration is elaborated which has the effect of bind
Air Force Academy - ME - 324
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 12 Java Threads A thread in Java is an instance of the Thread class (or a class that extends Thread). The Thread class provides methods to create, control and synchronise a thread. When a thread
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 5 Function and Procedure Abstractions Functions A function definition establishes name for a program entity which, when called, yields a value (of a specific type) which usually depends on one o
Air Force Academy - ME - 492
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 10 Synchronization in Concurrent Ada Programs Protected Variables In Ada 95 a simple mechanism: namely protected variables, was introduced for controlling access to shared data. A protected vari
Air Force Academy - ME - 324
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLecture 2 - Programming Language Concepts Every programming language has syntax and semantics: The syntax of a programming language is concerned with the form of expressions, commands and declaration
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 16 Object-Oriented Programming in Ada Tagged Types In the previous lecture we saw how a new type could be derived from an existing type and how such a type inherited the primitive operations of
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsLecture 14 Generics In the previous lecture the package IntStack provided an abstract data object namely a stack of integers. It should be clear that the implementation of a stack of floating point n
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 7 - More on Types Semi-Boolean Truth Values In some languages (for example C and C+, but not Java) there is no special Boolean type as such. Instead comparisons and other Boolean expressions pro
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 3 - Values, Types and Variables The term value refers to anything that results when an expression is evaluated, or an entity that may be stored in a memory cell within the computer, or which for
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 9 Concurrent Programming in Ada Tasks So far we have only considered sequential programs in which statements are obeyed in a single thread of control. However a program can also be built from tw
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsUnit 6 Renaming in Ada It is possible to give a new name to certain Ada entities using a renaming declaration. The following entities can be renamed: variables constants array elements packages recor
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 2 Solutions Solutions to the first lab class exercises may now be found on the module web-site and in the Unix directory ~barnesa/cs2130/lab1. Recall that you can access the module we
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 1 The Module Web-site Check that you can access the module Web-site by following the CS2130 link from my home page with URLhttp:/www.aston.ac.uk/~barnesaor following the links Prog
East Los Angeles College - CS - 2130
CS2130 Programming Language Concepts and ParadigmsPractical Class 3 The Ada.Command_Line and POSIX.Files Packages The purpose of this lab is to introduce a few more of the Ada Libraries available with the Gnat Ada system. which enable an Ada program
Air Force Academy - ME - 475
f4_3f4_4
CSU Fullerton - OPS - 234
AS/400 Operations Navigator It is now possible for a user to execute AS/400 commands without having to learn Command Language syntax. Also, for those users who are aware of CL but feel more productive by pointing and clicking with a graphical interfa
East Los Angeles College - CS - 2130
7#&lt;#R#:#}#P#3#P#3#Q3# #Q=##QI#QW#QW#QW#QW##Qc# #Qm# #Qw#Qw#Qw#Qw#Qw# #Q#Qp#Q #Qe#Q#Q#,#Q#Q#Q #Q#Q#Q#Q# #Q#R# # # ##CS2130 Programming Language Concepts and ParadigmsUnit 9 Concurrent Programming in AdaTasksSo far we have only considered sequentia
East Los Angeles College - CS - 2130
7#|#:#v6#%#3# #3#3#.#a#$#I#w# #p## # # # # #,#&quot;##&amp;# (#,#0#2#6# # ## #CS2130 Programming Language Concepts and ParadigmsUnit 4 - Bindings and ScopeBindingEach time execution of a program in a high-level programming language such as Ada reaches a dec
Air Force Academy - ME - 324
Iron and Iron-Fe3C Equilibrium Phase DiagramIron (Fe) * Occurs naturally in meteorites. Only a small quantity is of terrestrial origin. * Is the second most abundant metal (after aluminium) in the Earths crust. It constitutes about 95% of all the me
East Los Angeles College - CS - 2130
7#\t# #Y #$#.# #.# .#&gt;#CN#&lt;\# \# \# \## h# # r# # |#R|# |# |#R|# # U# #d# # #7# # # #R# # #v# # # ## #CS2130 Programming Language Concepts and ParadigmsUnit 10 Synchronization in Concurrent Ada ProgramsProtected VariablesIn Ada 95 a simple mechanis
Air Force Academy - ME - 492
Department of Mechanical Engineering University of Saskatchewan ME464.3 MATERIALS IN ENGINEERING DESIGN Mid-Term Examination Instructor: I. Oguocha Date: 1 March, 2002.Instructions 1. Answer ALL Questions Time: 1 hours 2. Class notes are allowed. C
UMBC - PHYSICS - 151
Find the Angles An 82 kg traffic light is supported by two cables, one pulling up and to the right with 500 N, the other pulling up and to the left with 643 N. Find the angle which each cable makes with the horizontal.
Air Force Academy - ME - 492
ME492.3MaterialsinEngineeringDesign DepartmentofMechanicalEngineering UniversityofSaskatchewan ASSIGNMENT#1SOLUTIONJanuary2009 Question #1 Several professions claim to design one thing or another. Typical examples include: Fashion designer/tailor (de
Air Force Academy - ME - 229
AutoCAD 10% Progress report 5% Log book 10% Design report 25% Presentation 20% Final exam 30% Assignments P/F WHMIS P/F If you receive a F, marks will be withheld until a satisfactory performance has been achieved.Final MarksThe marks represent ra
Air Force Academy - ME - 229
Four Layered Spherical Display Structure:Panoramic Display of Lumieres PhotostereosynthesisGARNET HERTZ: DESIGN PROPOSALGarnet Hertz 1 January 2008 garnethertz@gmail.comAbstract: Proposal for building of a custom four-layered transparent spher
CSU Fullerton - GAM - 666
GAM666 Introduction To Game ProgrammingWindows Programming in C+ You must use special libraries (aka APIs application programming interfaces) to make something other than a text-based program. The C+ choices are: The original Windows SDK (Softwa
Air Force Academy - ME - 229
ME 229 AutoCAD SectionAssignment # 6 Draw the following drafts: Sizes of mechanical parts according to the dimension shown Lines and text are to be properly defined in different layers. Model geometry, dims and text in model space Use Papers
CSU Fullerton - SYA - 710
When One Billion does not equal One Billion, or: Why your computers disk drive capacity doesnt appear to match the stated capacityA White Paperby James Wiebe, CEO WiebeTech LLC www.wiebetech.com 2003 WiebeTech LLC This paper may be reproduced in
East Los Angeles College - CS - 1110
CS1110 Introduction to Systematic Programming Week 3 - Practical Class 1Compiler Error Messages and Compiler Listings So far we have assumed that when you compile an Ada program everything goes smoothly. However suppose that the source file ( divide
East Los Angeles College - CS - 1110
CS111 Introduction to Systematic Programming Second Practical ClassIf you did not attend the first practical or if you did not complete the worksheet, work through the hand-out for that practical BEFORE working on this sheet. Open the file prog1.adb
East Los Angeles College - CS - 1110
7#,#i# #h#.#!#.#(#.# .# .# .#&lt;#P# # #&quot;#4#L# #P#,# #x#(#D# $# # D# #*# # .## ]#I# #w#/#V# ##%#(# #Introduction to Systematic ProgrammingUnit 7 - Writing Larger Programs7.1 IntroductionThe first few units of this course have advocated a four stage ap