COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen

Size: px
Start display at page:

Download "COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen"

Transcription

1 COP4020 Programmig Laguages Names, Scopes, ad Bidigs Prof. Robert va Egele

2 Overview Abstractios ad ames Bidig time Object lifetime Object storage maagemet Static allocatio Stack allocatio Heap allocatio Scope rules Static versus dyamic scopig Referece eviromets Overloadig ad polymorphism COP4020 Fall

3 Name = Abstractio Names eable programmers to refer to variables, costats, operatios, ad types Names are cotrol abstractios ad data abstractios for program fragmets ad data structures Cotrol abstractio: Subrouties (procedures ad fuctios) allow programmers to focus o maageable subset of program text, subroutie iterface hides implemetatio details Cotrol flow costructs (if-the, while, for, retur) hide low-level machie ops Data abstractio: Object-orieted classes hide data represetatio details behid a set of operatios Abstractio i the cotext of high-level programmig laguages refers to the degree or level of workig with code ad data Ehaces the level of machie-idepedece "Power" of costructs COP4020 Fall

4 Bidig Time A bidig is a associatio betwee a ame ad a etity Bidig time is the time at which a implemetatio decisio is made to create a ame «etity bidig: Laguage desig time: the desig of specific program costructs (sytax), primitive types, ad meaig (sematics) Laguage implemetatio time: fixatio of implemetatio costats such as umeric precisio, ru-time memory sizes, max idetifier ame legth, umber ad types of built-i exceptios, etc. Program writig time: the programmer's choice of algorithms ad data structures Compile time: the time of traslatio of high-level costructs to machie code ad choice of memory layout for data objects Lik time: the time at which multiple object codes (machie code files) ad libraries are combied ito oe executable Load time: whe the operatig system loads the executable i memory Ru time: whe a program executes COP4020 Fall

5 Bidig Time Examples Laguage desig: Sytax (ames «grammar) if (a>0) b=a; (C sytax style) if a>0 the b:=a ed if (Ada sytax style) Keywords (ames «builtis) class (C++ ad Java), edif or ed if (Fortra, space isigificat) Reserved words (ames «special costructs) mai (C), writel (Pascal) Meaig of operators (operator «operatio) + (add), % (mod), ** (power) Built-i primitive types (type ame «type) float, short, it, log, strig Laguage implemetatio Iteral represetatio of types ad literals (type «byte ecodig) 3.1 (IEEE 754) ad "foo bar (\0 termiated or embedded strig legth) Storage allocatio method for variables (static/stack/heap) COP4020 Fall

6 Bidig Time Examples (cot d) Compile time The specific type of a variable i a declaratio (ame«type) Storage allocatio method for a global or local variable (ame«allocatio mechaism) Liker Likig calls to static library routies (fuctio«address) pritf (i libc) Mergig ad likig multiple object codes ito oe executable Loader Loadig executable i memory ad adjustig absolute addresses Mostly i older systems that do ot have virtual memory Ru time Dyamic likig of libraries (library fuctio«library code) DLL, dylib Nostatic allocatio of space for variable (variable«address) Stack ad heap COP4020 Fall

7 The Effect of Bidig Time Early bidig times (before ru time) are associated with greater efficiecy ad clarity of program code Compilers make implemetatio decisios at compile time (avoidig to geerate code that makes the decisio at ru time) Sytax ad static sematics checkig is performed oly oce at compile time ad does ot impose ay ru-time overheads Late bidig times (at ru time) are associated with greater flexibility (but may leave programmers sometimes guessig what s goig o) Iterpreters allow programs to be exteded at ru time Laguages such as Smalltalk-80 with polymorphic types allow variable ames to refer to objects of multiple types at ru time Method bidig i object-orieted laguages must be late to support dyamic bidig COP4020 Fall

8 Bidig Lifetime versus Object Lifetime Key evets i object lifetime: Object creatio Creatio of bidigs The object is maipulated via its bidig Deactivatio ad reactivatio of (temporarily ivisible) bidigs Destructio of bidigs Destructio of objects Bidig lifetime: time betwee creatio ad destructio of bidig to object Example: a poiter variable is set to the address of a object Example: a formal argumet is boud to a actual argumet Object lifetime: time betwee creatio ad destructio of a object COP4020 Fall

9 Bidig Lifetime versus Object Lifetime (cot d) Bidigs are temporarily ivisible whe code is executed where the bidig (ame «object) is out of scope Memory leak: object ever destroyed (bidig to object may have bee destroyed, rederig access impossible) Daglig referece: object destroyed before bidig is destroyed Garbage collectio prevets these allocatio/deallocatio problems COP4020 Fall

10 C++ Example { } SomeClass* myobject = ew SomeClass;... { OtherClass myobject;... // the myobject ame is boud to other object... }... // myobject bidig is visible agai... myobject->actio() // myobject i actio(): // the ame is ot i scope // but object is boud to this delete myobject; // myobject is a daglig referece COP4020 Fall

11 Object Storage Objects (program data ad code) have to be stored i memory durig their lifetime Static objects have a absolute storage address that is retaied throughout the executio of the program Global variables ad data Subroutie code ad class method code Stack objects are allocated i last-i first-out order, usually i cojuctio with subroutie calls ad returs Actual argumets passed by value to a subroutie Local variables of a subroutie Heap objects may be allocated ad deallocated at arbitrary times, but require a expesive storage maagemet algorithm Example: Lisp lists Example: Java class istaces are always stored o the heap COP4020 Fall

12 Typical Program ad Data Layout i Memory Upper addr Virtual memory address space stack heap static data Program code is at the bottom of the memory regio (code sectio) The code sectio is protected from ru-time modificatio by the OS Static data objects are stored i the static regio Stack grows dowward Heap grows upward code 0000 COP4020 Fall

13 Static Allocatio Program code is statically allocated i most implemetatios of imperative laguages Statically allocated variables are history sesitive Global variables keep state durig etire program lifetime Static local variables i C fuctios keep state across fuctio ivocatios Static data members are shared by objects ad keep state durig program lifetime Advatage of statically allocated object is the fast access due to absolute addressig of the object So why ot allocate local variables statically? Problem: static allocatio of local variables caot be used for recursive subrouties: each ew fuctio istatiatio eeds fresh locals COP4020 Fall

14 Static Allocatio i Fortra 77 Temporary storage (e.g. for expressio evaluatio) Local variables Bookkeepig (e.g. saved CPU registers) Retur address Subroutie argumets ad returs Typical static subroutie frame layout Fortra 77 has o recursio Global ad local variables are statically allocated as decided by the compiler Global ad local variables are refereced at absolute addresses Avoids overhead of creatio ad destructio of local objects for every subroutie call Each subroutie i the program has a subroutie frame that is statically allocated This subroutie frame stores all subroutie-relevat data that is eeded to execute COP4020 Fall

15 Stack Allocatio Each istace of a subroutie that is active has a subroutie frame (sometimes called activatio record) o the ru-time stack Compiler geerates subroutie callig sequece to setup frame, call the routie, ad to destroy the frame afterwards Method ivocatio works the same way, but i additio methods are typically dyamically boud Subroutie frame layouts vary betwee laguages, implemetatios, ad machie platforms COP4020 Fall

16 Typical Stack-Allocated Subroutie Frame Lower addr Temporary storage (e.g. for expressio evaluatio) Local variables Bookkeepig (e.g. saved CPU registers) A frame poiter (fp) poits to the frame of the curretly active subroutie at ru time Subroutie argumets, local variables, ad retur values are accessed by costat address offsets from the fp fp Higher addr Retur address Subroutie argumets ad returs Typical subroutie frame layout COP4020 Fall

17 Subroutie Frames o the Stack sp fp Higher addr A B A M Temporaries Local variables Bookkeepig Retur address Argumets Temporaries Local variables Bookkeepig Retur address Argumets Temporaries Local variables Bookkeepig Retur address Argumets Temporaries Local variables Bookkeepig Retur address Argumets Stack growth Subroutie frames are pushed ad popped oto/from the rutime stack The stack poiter (sp) poits to the ext available free space o the stack to push a ew frame oto whe a subroutie is called The frame poiter (fp) poits to the frame of the curretly active subroutie, which always the topmost frame o the stack The fp of the previous active frame is saved i the curret frame ad restored after the call I this example: M called A A called B B called A COP4020 Fall

18 Example Subroutie Frame Lower addr fp-32 fp fp+4 Higher addr Temporaries -36: foo (4 bytes) -32: bar (8 bytes) -24: p (4 bytes) Bookkeepig (16 bytes) Retur address to the caller of P (4 bytes) 0: a (4 bytes) 4: b (4 bytes) The size of the types of local variables ad argumets determies the fp offset i a frame Example Pascal procedure: procedure P(a:iteger, var b:real) (* a is passed by value b is passed by referece, = poiter to b's value *) var foo:iteger;(* 4 bytes *) bar:real; (* 8 bytes *) p:^iteger; (* 4 bytes *) begi... ed COP4020 Fall

19 Heap Allocatio Implicit heap allocatio: Doe automatically Java class istaces are placed o the heap Scriptig laguages ad fuctioal laguages make extesive use of the heap for storig objects Some procedural laguages allow array declaratios with rutime depedet array size Resizable character strigs Explicit heap allocatio: Statemets ad/or fuctios for allocatio ad deallocatio Malloc/free, ew/delete COP4020 Fall

20 Heap Allocatio Algorithms Heap allocatio is performed by searchig the heap for available free space For example, suppose we wat to allocate a ew object E of 20 bytes, where would it fit? Object A Free Object B Object C Free Object D Free 30 bytes 8 bytes 10 bytes 24 bytes 24 bytes 8 bytes 20 bytes Deletio of objects leaves free blocks i the heap that ca be reused Iteral heap fragmetatio: if allocated object is smaller tha the free block the extra space is wasted Exteral heap fragmetatio: smaller free blocks caot always be reused resultig i wasted space COP4020 Fall

21 Heap Allocatio Algorithms (cot d) Maitai a liked list of free heap blocks First-fit: select the first block i the list that is large eough Best-fit: search the etire list for the smallest free block that is large eough to hold the object If a object is smaller tha the block, the extra space ca be added to the list of free blocks Whe a block is freed, adjacet free blocks are coalesced Buddy system: use heap pools of stadard sized blocks of size 2 k If o free block is available for object of size betwee 2 k-1 +1 ad 2 k the fid block of size 2 k+1 ad split it i half, addig the halves to the pool of free 2 k blocks, etc. Fiboacci heap: use heap pools of stadard size blocks accordig to Fiboacci umbers More complex but leads to slower iteral fragmatatio COP4020 Fall

22 Ulimited Extet A object declared i a local scope has ulimited extet if its lifetime potetially cotiues idefiitely, as log as bidigs to the object exist that may be out of scope A local stack-allocated variable has a lifetime limited to the lifetime of the subroutie I C/C++ fuctios should ever retur poiters to local variables Ulimited extet requires static or heap allocatio Issues with static: limited, o mechaism to allocate more variables Issues with heap: should deallocate whe o loger refereced by bidigs Solutio usig heap: garbage collectio removes object whe o loger boud (by ay refereces) COP4020 Fall

23 Garbage Collectio Explicit maual deallocatio errors are amog the most expesive ad hard to detect problems i real-world applicatios If a object is deallocated too soo, a referece to the object becomes a daglig referece If a object is ever deallocated, the program leaks memory Automatic garbage collectio removes all objects from the heap that are ot accessible, i.e. are ot refereced Used i Lisp, Scheme, Prolog, Ada, Java, Haskell Disadvatage is GC overhead, but GC algorithm efficiecy has bee improved Not always suitable for real-time processig COP4020 Fall

24 Ada C Storage Allocatio Compared C++ Java Fortra77 Pascal N/A Static Stack Heap global variables; static local variables Same as C, ad static class members N/A global variables (i commo blocks), local variables, ad subroutie argumets (implemetatio depedet); SAVE forces static allocatio global variables (compiler depedet) local variables ad subroutie argumets of fixed size local variables ad subroutie argumets Same as C oly local variables of primitive types local variables ad subroutie argumets (implemetatio depedet implicit: local variables of variable size; explicit: ew (destructio with garbage collectio or explicit with uchecked deallocatio) explicit with malloc ad free explicit with ew ad delete implicit: all class istaces (destructio with garbage collectio) N/A global variables Explicit: ew ad dispose (compiler depedet), local variables, ad subroutie argumets COP4020 Fall

25 Scope Scope is the textual regio of a program i which a ame-to-object bidig is active Statically scoped laguage: the scope of bidigs is determied at compile time Used by almost all but a few programmig laguages More ituitive to user compared to dyamic scopig Dyamically scoped laguage: the scope of bidigs is determied at ru time Used i Lisp (early versios), APL, Sobol, ad Perl (selectively) COP4020 Fall

26 Effect of Static Scopig Program executio: a:iteger bidig mai() a:=2 secod() a:iteger first() a:=1 write_iteger(a) Program prits 1 The followig pseudo-code program demostrates the effect of scopig o variable bidigs: a:iteger procedure first a:=1 procedure secod a:iteger first() procedure mai a:=2 secod() write_iteger(a) COP4020 Fall

27 Effect of Dyamic Scopig Program executio: a:iteger mai() a:=2 secod() bidig a:iteger first() a:=1 write_iteger(a) Program prits 2 The followig pseudo-code program demostrates the effect of scopig o variable bidigs: a:iteger procedure first a:=1 Bidig depeds o executio procedure secod a:iteger first() procedure mai a:=2 secod() write_iteger(a) COP4020 Fall

28 Static Scopig The bidigs betwee ames ad objects ca be determied by examiatio of the program text Scope rules of a program laguage defie the scope of variables ad subrouties, which is the regio of program text i which a ame-to-object bidig is usable Early Basic: all variables are global ad visible everywhere Fortra 77: the scope of a local variable is limited to a subroutie; the scope of a global variable is the whole program text uless it is hidde by a local variable declaratio with the same variable ame Algol 60, Pascal, ad Ada: these laguages allow ested subrouties defiitios ad adopt the closest ested scope rule with slight variatios i implemetatio COP4020 Fall

29 Closest Nested Scope Rule procedure P1(A1:T1) var X:real;... procedure P2(A2:T2);... procedure P3(A3:T3);... begi (* body of P3: P3,A3,P2,A2,X of P1,P1,A1 are visible *) ed;... begi (* body of P2: P3,P2,A2,X of P1,P1,A1 are visible *) ed; procedure P4(A4:T4);... fuctio F1(A5:T5):T6; var X:iteger;... begi (* body of F1: X of F1,F1,A5,P4,A4,P2,P1,A1 are visible *) ed;... begi (* body of P4: F1,P4,A4,P2,X of P1,P1,A1 are visible *) ed;... begi (* body of P1: X of P1,P1,A1,P2,P4 are visible *) ed To fid the object refereced by a give ame: Look for a declaratio i the curret iermost scope If there is oe, look for a declaratio i the immediately surroudig scope, etc. COP4020 Fall

30 Static Scope Implemetatio with Static Liks Scope rules are desiged so that we ca oly refer to variables that are alive: the variable must have bee stored i the frame of a subroutie If a variable is ot i the local scope, we are sure there is a frame for the surroudig scope somewhere below o the stack: The curret subroutie ca oly be called whe it was visible The curret subroutie is visible oly whe the surroudig scope is active Each frame o the stack cotais a static lik poitig to the frame of the static paret COP4020 Fall

31 Example Static Liks Subrouties C ad D are declared ested i B B is static paret of C ad D B ad E are ested i A A is static paret of B ad E The fp poits to the frame at the top of the stack to access locals The static lik i the frame poits to the frame of the static paret COP4020 Fall

32 Static Chais How do we access o-local objects? The static liks form a static chai, which is a liked list of static paret frames Whe a subroutie at estig level j has a referece to a object declared i a static paret at the surroudig scope ested at level k, the j-k static liks forms a static chai that is traversed to get to the frame cotaiig the object The compiler geerates code to make these traversals over frames to reach o-local objects COP4020 Fall

33 Example Static Chais Subroutie A is at estig level 1 ad C at estig level 3 Whe C accesses a object of A, 2 static liks are traversed to get to A's frame that cotais that object COP4020 Fall

34 Out of Scope No-local objects ca be hidde by local ame-to-object bidigs ad the scope is said to have a hole i which the o-local bidig is temporarily iactive but ot destroyed Some laguages, otably Ada ad C++ use qualifiers or scope resolutio operators to access o-local objects that are hidde P1.X i Ada to access variable X of P1 ad ::X to access global variable X i C++ COP4020 Fall

35 Out of Scope Example procedure P1; var X:real; procedure P2; var X:iteger begi... (* X of P1 is hidde *) ed; begi... ed P2 is ested i P1 P1 has a local variable X P2 has a local variable X that hides X i P1 Whe P2 is called, o extra code is executed to iactivate the bidig of X to P1 COP4020 Fall

36 Dyamic Scope Scope rule: the "curret" bidig for a give ame is the oe ecoutered most recetly durig executio Typically adopted i (early) fuctioal laguages that are iterpreted Perl v5 allows you to choose scope method for each variable separately With dyamic scope: Name-to-object bidigs caot be determied by a compiler i geeral Easy for iterpreter to look up ame-to-object bidig i a stack of declaratios Geerally cosidered to be "a bad programmig laguage feature" Hard to keep track of active bidigs whe readig a program text Most laguages are ow compiled, or a compiler/iterpreter mix Sometimes useful: Uix eviromet variables have dyamic scope COP4020 Fall

37 Dyamic Scopig Problems I this example, fuctio scaled_score probably does ot do what the programmer iteded: with dyamic scopig, max_score i scaled_score is boud to foo's local variable max_score after foo calls scaled_score, which was the most recet bidig durig executio: max_score:iteger fuctio scaled_score(raw_score:iteger):real retur raw_score/max_score* procedure foo max_score:real := 0... foreach studet i class studet.percet := scaled_score(studet.poits) if studet.percet > max_score max_score := studet.percet COP4020 Fall

38 Dyamic Scope Implemetatio with Bidigs Stacks Each time a subroutie is called, its local variables are pushed o a stack with their ame-to-object bidig Whe a referece to a variable is made, the stack is searched top-dow for the variable's ame-to-object bidig After the subroutie returs, the bidigs of the local variables are popped Differet implemetatios of a bidig stack are used i programmig laguages with dyamic scope, each with advatages ad disadvatages COP4020 Fall

39 Referecig Eviromets If a subroutie is passed as a argumet to aother subroutie, whe are the static/dyamic scopig rules applied? Whe the referece to the subroutie is first created (i.e. whe it is passed as a argumet) Or whe the argumet subroutie is fially called That is, what is the referecig eviromet of a subroutie passed as a argumet? Evetually the subroutie passed as a argumet is called ad may access o-local variables which by defiitio are i the referecig eviromet of usable bidigs The choice is fudametal i laguages with dyamic scope The choice is limited i laguages with static scope COP4020 Fall

40 Effect of Deep Bidig i Dyamically-Scoped Laguages Program executio: mai(p) thres:iteger bidig thres := 35 show(p,older) thres:iteger thres := 20 older(p) retur p.age>thres if retur value is true write(p) Program prits persos older tha 35 The followig program demostrates the differece betwee deep ad shallow bidig: fuctio older(p:perso):boolea retur p.age>thres procedure show(p:perso,c:fuctio) thres:iteger thres := 20 if c(p) write(p) procedure mai(p) thres:iteger thres := 35 show(p,older) COP4020 Fall

41 Effect of Shallow Bidig i Dyamically-Scoped Laguages Program executio: mai(p) thres:iteger thres := 35 show(p,older) thres:iteger bidig thres := 20 older(p) retur p.age>thres if retur value is true write(p) Program prits persos older tha 20 The followig program demostrates the differece betwee deep ad shallow bidig: fuctio older(p:perso):boolea retur p.age>thres procedure show(p:perso,c:fuctio) thres:iteger thres := 20 if c(p) write(p) procedure mai(p) thres:iteger thres := 35 show(p,older) COP4020 Fall

42 Implemetig Deep Bidigs with Subroutie Closures The referecig eviromet is budled with the subroutie as a closure ad passed as a argumet A subroutie closure cotais A poiter to the subroutie code The curret set of ame-to-object bidigs Depedig o the implemetatio, the whole curret set of bidigs may have to be copied or the head of a list is copied if liked lists are used to implemet a stack of bidigs COP4020 Fall

43 Statemet Blocks C Ada C++ Java C# { it t = a; a = b; b = t; } declare t:iteger begi t := a; a := b; b := t; ed; { it a,b;... it t; t=a; a=b; b=t;... } I Algol, C, ad Ada local variables are declared i a block or compoud statemet I C++, Java, ad C# declaratios may appear aywhere statemets ca be used ad the scope exteds to the ed of the block Local variables declared i ested blocks i a sigle fuctio are all stored i the subroutie frame for that fuctio (most programmig laguages, e.g. C/C++, Ada, Java) COP4020 Fall

44 Modules ad Module Scope Modules are the most importat feature of a programmig laguage that supports the costructio of large applicatios Teams of programmers ca work o separate modules i a project No laguage support for modules i C ad Pascal Modula-2 modules, Ada packages, C++ amespaces Java packages Scopig: modules ecapsulate variables, data types, ad subrouties i a package Objects iside are visible to each other Objects iside are ot visible outside uless exported Objects outside are ot visible iside uless imported A module iterface specifies exported variables, data types, ad subrouties The module implemetatio is compiled separately ad implemetatio details are hidde from the user of the module COP4020 Fall

45 First, Secod, ad Third-Class Subrouties First-class object: a object etity that ca be passed as a parameter, retured from a subroutie, ad assiged to a variable Primitive types such as itegers i most programmig laguages Secod-class object: a object that ca be passed as a parameter, but ot retured from a subroutie or assiged to a variable Fixed-size arrays i C/C++ Third-class object: a object that caot be passed as a parameter, caot be retured from a subroutie, ad caot be assiged to a variable Labels of goto-statemets ad subrouties i Ada 83 Fuctios i Lisp, ML, ad Haskell are urestricted first-class objects With certai restrictios, subrouties are first-class objects i Modula-2 ad 3, Ada 95, (C ad C++ use fuctio poiters) COP4020 Fall

46 First-Class Subroutie Implemetatio Requiremets fuctio ew_it_priter(port:iteger):procedure procedure prit_it(val:it) begi write(port, val) ed begi retur prit_it ed procedure mai begi myprit:procedure myprit := ew_it_priter(80) myprit(7) ed Problem: subroutie retured as object may lose part of its referece eviromet i its closure! Procedure prit_it uses argumet port of ew_it_priter, which is i the referecig eviromet of prit_it After the call to ew_it_priter, argumet port should be kept alive somehow (it is ormally removed from the ru-time stack ad it will become a daglig referece) COP4020 Fall

47 First-Class Subroutie Implemetatios I fuctioal laguages, local objects have ulimited extet: their lifetime cotiue idefiitely Local objects are allocated o the heap Garbage collectio will evetually remove uused objects I imperative laguages, local objects have limited extet with stack allocatio To avoid the problem of daglig refereces, alterative mechaisms are used: C, C++, ad Java: o ested subroutie scopes Modula-2: oly outermost routies are first-class Ada 95 "cotaimet rule": ca retur a ier subroutie uder certai coditios COP4020 Fall

48 Overloaded Bidigs A ame that ca refer to more tha oe object is said to be overloaded Example: + (additio) is used for iteger ad ad floatig-poit additio i most programmig laguages Sematic rules of a programmig laguage require that the cotext of a overloaded ame should cotai sufficiet clues to deduce the iteded bidig Sematic aalyzer of compiler uses type checkig to resolve bidigs Ada ad C++ fuctio overloadig eables programmer to defie alterative implemetatios depedig o argumet types Ada, C++, ad Fortra 90 allow built-i operators to be overloaded with user-defied fuctios, which ehaces expressiveess but may mislead programmers that are ufamiliar with the code COP4020 Fall

49 Overloaded Bidigs Example Example i C++: struct complex {...}; eum base {dec, bi, oct, hex}; void prit_um(it ) {... } void prit_um(it, base b) {... } void prit_um(struct complex c) {... } COP4020 Fall

50 Dyamic Bidigs Object data VMT poiter Method #4 Overridde Method code Method #4 Derived Class VMT Base Class VMT Polymorphic fuctios ad operators based o overloadig are statically boud by the compiler based o type iformatio Polymorphism with dyamic bidigs is supported by class iheritace (C++ virtual methods) Each class has a virtual method table (VMT) with poiters to methods, where each method is idexed ito the table Method ivocatio proceeds by gettig the class VMT from the object ad idexig it to select the method to ivoke Method code COP4020 Fall

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen COP4020 Programming Languages Names, Scopes, and Bindings Prof. Robert van Engelen Overview Abstractions and names Binding time Object lifetime Object storage management Static allocation Stack allocation

More information

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen COP4020 mig Laguages Compilers ad Iterpreters Prof. Robert va Egele Overview Commo compiler ad iterpreter cofiguratios Virtual machies Itegrated developmet eviromets Compiler phases Lexical aalysis Sytax

More information

6. Names, Scopes, and Bindings

6. Names, Scopes, and Bindings Copyright (C) R.A. van Engelen, FSU Department of Computer Science, 2000-2004 6. Names, Scopes, and Bindings Overview Names Binding time Object lifetime Object storage management Static allocation Stack

More information

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000. 5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator

More information

Names and Abstractions: What s in a Name?

Names and Abstractions: What s in a Name? Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Names, Scopes, and Bindings Binding time Object lifetime Object storage management Static allocation Stack allocation Heap allocation

More information

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion Aoucemets HW6 due today HW7 is out A team assigmet Submitty page will be up toight Fuctioal correctess: 75%, Commets : 25% Last class Equality testig eq? vs. equal? Higher-order fuctios map, foldr, foldl

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen COP4020 Programmig Laguages Subrouties ad Parameter Passig Prof. Robert va Egele Overview Parameter passig modes Subroutie closures as parameters Special-purpose parameters Fuctio returs COP4020 Fall 2016

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programmig Laguages Fuctioal Programmig Prof. Robert va Egele Overview What is fuctioal programmig? Historical origis of fuctioal programmig Fuctioal programmig today Cocepts of fuctioal programmig

More information

Τεχνολογία Λογισμικού

Τεχνολογία Λογισμικού ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τεχνολογία Λογισμικού, 7ο/9ο εξάμηνο 2018-2019 Τεχνολογία Λογισμικού Ν.Παπασπύρου, Αν.Καθ. ΣΗΜΜΥ, ickie@softlab.tua,gr

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,

More information

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago CMSC 22200 Computer Architecture Lecture 12: Virtual Memory Prof. Yajig Li Uiversity of Chicago A System with Physical Memory Oly Examples: most Cray machies early PCs Memory early all embedded systems

More information

CS 11 C track: lecture 1

CS 11 C track: lecture 1 CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material

More information

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers? CSE401: Itroductio to Compiler Costructio Larry Ruzzo Sprig 2004 Today s objectives Admiistrative details Defie compilers ad why we study them Defie the high-level structure of compilers Associate specific

More information

n Haskell n Syntax n Lazy evaluation n Static typing and type inference n Algebraic data types n Pattern matching n Type classes

n Haskell n Syntax n Lazy evaluation n Static typing and type inference n Algebraic data types n Pattern matching n Type classes Aoucemets Quiz 7 HW 9 is due o Friday Raibow grades HW 1-6 plus 8. Please, read our commets o 8! Exam 1-2 Quiz 1-6 Ay questios/cocers, let us kow ASAP Last Class Haskell Sytax Lazy evaluatio Static typig

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies

More information

implement language system

implement language system Outlie Priciples of programmig laguages Lecture 3 http://few.vu.l/~silvis/ppl/2007 Part I. Laguage systems Part II. Fuctioal programmig. First look at ML. Natalia Silvis-Cividjia e-mail: silvis@few.vu.l

More information

From last week. Lecture 5. Outline. Principles of programming languages

From last week. Lecture 5. Outline. Principles of programming languages Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for

More information

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1 Classes ad Objects jvo@ualg.pt José Valete de Oliveira 4-1 Agai: Distace betwee poits withi the first quadrat Sample iput Sample output 1 1 3 4 2 jvo@ualg.pt José Valete de Oliveira 4-2 1 The simplest

More information

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types Aoucemets HW9 due today HW10 comig up, will post after class Team assigmet Data abstractio (types) ad cotrol abstractio (parameter passig) Due o Tuesday, November 27 th Last Class Types Type systems Type

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

DATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Data structures. Appetizer. Appetizer

DATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Data structures. Appetizer. Appetizer Data structures DATA STRUCTURES Static problems. Give a iput, produce a output. Ex. Sortig, FFT, edit distace, shortest paths, MST, max-flow,... amortized aalysis biomial heaps Fiboacci heaps uio-fid Dyamic

More information

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes Prelimiaries Liked Lists public class StrageObject { Strig ame; StrageObject other; Arrays are ot always the optimal data structure: A array has fixed size eeds to be copied to expad its capacity Addig

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

IMP: Superposer Integrated Morphometrics Package Superposition Tool

IMP: Superposer Integrated Morphometrics Package Superposition Tool IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College

More information

Appendix D. Controller Implementation

Appendix D. Controller Implementation COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Heaps. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 201 Heaps 201 Goodrich ad Tamassia xkcd. http://xkcd.com/83/. Tree. Used with permissio uder

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS) CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

Chapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings

Chapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings Operatig Systems: Iterals ad Desig Priciples Chapter 4 Threads Nith Editio By William Stalligs Processes ad Threads Resource Owership Process icludes a virtual address space to hold the process image The

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 19 Query Optimizatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Query optimizatio Coducted by a query optimizer i a DBMS Goal:

More information

Goals of the Lecture Object Constraint Language

Goals of the Lecture Object Constraint Language Goals of the Lecture Object Costrait Laguage Object-Orieted Aalysis ad Desig - Fall 1998 Preset the Object Costrait Laguage Ð As best as possible, with the limited iformatio available from UML i a Nutshell

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle: Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates

More information

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software Structurig Redudacy for Fault Tolerace CSE 598D: Fault Tolerat Software What do we wat to achieve? Versios Damage Assessmet Versio 1 Error Detectio Iputs Versio 2 Voter Outputs State Restoratio Cotiued

More information

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5.

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5. Morga Kaufma Publishers 26 February, 208 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Virtual Memory Review: The Memory Hierarchy Take advatage of the priciple

More information

Solutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer

Solutions to Final COMS W4115 Programming Languages and Translators Monday, May 4, :10-5:25pm, 309 Havemeyer Departmet of Computer ciece Columbia Uiversity olutios to Fial COM W45 Programmig Laguages ad Traslators Moday, May 4, 2009 4:0-5:25pm, 309 Havemeyer Closed book, o aids. Do questios 5. Each questio is

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 26 Ehaced Data Models: Itroductio to Active, Temporal, Spatial, Multimedia, ad Deductive Databases Copyright 2016 Ramez Elmasri ad Shamkat B.

More information

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5 Morga Kaufma Publishers 26 February, 28 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Set-Associative Cache Architecture Performace Summary Whe CPU performace icreases:

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 22 Database Recovery Techiques Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Recovery algorithms Recovery cocepts Write-ahead

More information

COMP Parallel Computing. PRAM (1): The PRAM model and complexity measures

COMP Parallel Computing. PRAM (1): The PRAM model and complexity measures COMP 633 - Parallel Computig Lecture 2 August 24, 2017 : The PRAM model ad complexity measures 1 First class summary This course is about parallel computig to achieve high-er performace o idividual problems

More information

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then UCLA PIC 10 B Problem Solvig usig C++ Programmig Ivo Diov, Asst. Prof. i Mathematics, Neurology, Statistics Istructor: Teachig Assistat: Suzae Nezzar, Mathematics Chapter 13 Templates for More Abstractio

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs

More information

Programming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen

Programming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen Programmig with Shared Memory PART II HPC Sprig 2017 Prof. Robert va Egele Overview Sequetial cosistecy Parallel programmig costructs Depedece aalysis OpeMP Autoparallelizatio Further readig HPC Sprig

More information

CMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago

CMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago CMSC 22200 Computer Architecture Lecture 3: ISA ad Itroductio to Microarchitecture Prof. Yajig Li Uiversity of Chicago Lecture Outlie ISA uarch (hardware implemetatio of a ISA) Logic desig basics Sigle-cycle

More information

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that

More information

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig

More information

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations Chapter 14 Graph class desig Bjare Stroustrup Abstract We have discussed classes i previous lectures Here, we discuss desig of classes Library desig cosideratios Class hierarchies (object-orieted programmig)

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

Data diverse software fault tolerance techniques

Data diverse software fault tolerance techniques Data diverse software fault tolerace techiques Complemets desig diversity by compesatig for desig diversity s s limitatios Ivolves obtaiig a related set of poits i the program data space, executig the

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

n Haskell n Covered syntax, lazy evaluation, static typing n Algebraic data types and pattern matching n Type classes n Monads and more n Types

n Haskell n Covered syntax, lazy evaluation, static typing n Algebraic data types and pattern matching n Type classes n Monads and more n Types Aoucemets Exam 2 is graded, but I will eed some time to go over it I ll release grades this eveig (figers crossed!) Raibow grades: HW1-6, Exam 1-2, Quiz 1-5 Will post aswer key Still gradig: Quiz 6, HW7

More information

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control EE 459/500 HDL Based Digital Desig with Programmable Logic Lecture 13 Cotrol ad Sequecig: Hardwired ad Microprogrammed Cotrol Refereces: Chapter s 4,5 from textbook Chapter 7 of M.M. Mao ad C.R. Kime,

More information

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998 Su Microsystems, Ic. 2550 Garcia Aveue Moutai View, CA 94045 415 960-1300 X3T10/95-229, Revisio 0 April 18, 1998 % Su Logo for Joh Lohmeyer Chairperso, X3T10 Symbios Logic Ic. 1635 Aeroplaza Drive Colorado

More information

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1 CS200: Hash Tables Prichard Ch. 13.2 CS200 - Hash Tables 1 Table Implemetatios: average cases Search Add Remove Sorted array-based Usorted array-based Balaced Search Trees O(log ) O() O() O() O(1) O()

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Uiversity of Waterloo Departmet of Electrical ad Computer Egieerig ECE 250 Algorithms ad Data Structures Midterm Examiatio ( pages) Istructor: Douglas Harder February 7, 2004 7:30-9:00 Name (last, first)

More information

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013 Code Review s Authors: Mika V. Mätylä ad Casper Lasseius Origial versio: 4 Sep, 2007 Made available olie: 24 April, 2013 This documet cotais further details of the code review defects preseted i [1]. of

More information

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 3 More Flow of Cotrol Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 3.1 Usig Boolea Expressios 3.2 Multiway Braches 3.3 More about C++ Loop Statemets 3.4 Desigig Loops Copyright

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms

More information

Definitions. Error. A wrong decision made during software development

Definitions. Error. A wrong decision made during software development Debuggig Defiitios Error A wrog decisio made durig software developmet Defiitios 2 Error A wrog decisio made durig software developmet Defect bug sometimes meas this The term Fault is also used Property

More information

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup   Note: Chapter 4 Computatio Bjare Stroustrup www.stroustrup.com/programmig Abstract Today, I ll preset the basics of computatio. I particular, we ll discuss expressios, how to iterate over a series of values

More information

Inductive Definition to Recursive Function

Inductive Definition to Recursive Function PDS: CS 11002 Computer Sc & Egg: IIT Kharagpur 1 Iductive Defiitio to Recursive Fuctio PDS: CS 11002 Computer Sc & Egg: IIT Kharagpur 2 Factorial Fuctio Cosider the followig recursive defiitio of the factorial

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Cocurrecy Threads ad Cocurrecy i Java: Part 1 What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Single-Cycle Disadvantages & Advantages

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Single-Cycle Disadvantages & Advantages COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 4 The Processor Pipeliig Sigle-Cycle Disadvatages & Advatages Clk Uses the clock cycle iefficietly the clock cycle must

More information

High-Order Language APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL

High-Order Language APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL Chapter 2 C High-Order Laguage APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL 6 ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL MICROCODE LEVEL LOGIC GATE LEVEL Figure 2. 7 6 5 4

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Threads ad Cocurrecy i Java: Part 1 1 Cocurrecy What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

Lecture 1. Topics. Principles of programming languages (2007) Lecture 1. What makes programming languages such an interesting subject?

Lecture 1. Topics. Principles of programming languages (2007) Lecture 1. What makes programming languages such an interesting subject? Priciples of programmig laguages (2007) Lecture 1 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l Lecture 1. Topics Studet survey Itroductio History of major programmig

More information

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..

More information

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS APPLICATION NOTE PACE175AE BUILT-IN UNCTIONS About This Note This applicatio brief is iteded to explai ad demostrate the use of the special fuctios that are built ito the PACE175AE processor. These powerful

More information

Baan Tools User Management

Baan Tools User Management Baa Tools User Maagemet Module Procedure UP008A US Documetiformatio Documet Documet code : UP008A US Documet group : User Documetatio Documet title : User Maagemet Applicatio/Package : Baa Tools Editio

More information

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation

Task scenarios Outline. Scenarios in Knowledge Extraction. Proposed Framework for Scenario to Design Diagram Transformation 6-0-0 Kowledge Trasformatio from Task Scearios to View-based Desig Diagrams Nima Dezhkam Kamra Sartipi {dezhka, sartipi}@mcmaster.ca Departmet of Computig ad Software McMaster Uiversity CANADA SEKE 08

More information

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

CMPT 125 Assignment 2 Solutions

CMPT 125 Assignment 2 Solutions CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address

More information

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e)

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e) Appedix (RASD 3/e) MACIASZEK, L.A. (2007): Requiremets Aalysis ad System Desig, 3 rd ed. Addiso Wesley, Harlow Eglad ISBN 978-0-321-44036-5 Appedix Fudametals of Object Techology Pearso Educatio Limited

More information

BEA Tuxedo. Creating CORBA Server Applications

BEA Tuxedo. Creating CORBA Server Applications BEA Tuxedo Creatig CORBA Server Applicatios BEA Tuxedo Release 8.0 Documet Editio 8.0 Jue 2001 Copyright Copyright 2001 BEA Systems, Ic. All Rights Reserved. Restricted Rights Leged This software ad documetatio

More information

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8 The Implemetatio of Data Structures i Versio 5 of Ico* Ralph E. Gr is wo Id TR 85-8 April 1, 1985 Departmet of Computer Sciece The Uiversity of Arizoa Tucso. Arizoa 85721 This work was supported by the

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

More information

Transitioning to BGP

Transitioning to BGP Trasitioig to BGP ISP Workshops These materials are licesed uder the Creative Commos Attributio-NoCommercial 4.0 Iteratioal licese (http://creativecommos.org/liceses/by-c/4.0/) Last updated 24 th April

More information