Class Note for CS 403 at UA-Programming Languages (24)
Class Note for CS 403 at UA-Programming Languages (24)
Popular in Course
Popular in Department
This 6 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Alabama - Tuscaloosa taught by a professor in Fall. Since its upload, it has received 16 views.
Reviews for Class Note for CS 403 at UA-Programming Languages (24)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CS 403 11262002 0 Today Paper assignment is posted Any questions Discuss Ada m 2mm cs 403 Class Names Schedule 0 Next Tuesday Read Ada chapter 8 Turn in Paper assignment Course Evaluations Some openended questions How can we improve this course Next Thursday Read chapter 14 very short m 2mm cs 403 Class Names Grades online 0 Your grades for all the assignments I ve graded are on the website Exam 2 is there and bonus points but not the Scheme paper l Exam 2 key is posted Course average calculated 3 ways with slightly different weights then the Max is taken With and without the Final Exam figured in m 2mm cs 403 Class Names Ada History amp Motivation Software Crisis 9 SW costs were increasing without any bound in sight Possible solutions Modules largely independent of each other Each major design decision should be hidden in one module Abstract Data Types ADTs DoDefense Spending 3 billionyear on software Had to support SW in 400 different languages m 2mm cs ACEClassNafzs P A DoD decided a new language DoD was largely responsible forthe initial success of COBOL Wanted one language that would do everything they needed from embedded real time SW to accounting SW and Al SW Series of language specifications 1975 Strawman 1975 Woodenman 1979 Steelman m 2mm cs ACEClassNafzs P Major Design Goals Do everything the DoD needs Information Hiding Verification Do you want a smart weapon with buggy SW Concurrency No subsets or supersets would be allowed Guaranteed portability no proprietary features Result Very much like Pascal amp Algol m 2mm cs ACEClassNafzs P 26 Structural Organization Blocks very similar to Pascal amp Algol 1 Declarations constants amp variables Object Type Subprogram overloading allowed Package a module Task anothertype of module 2 Expressions 3 Statements 4 Types mewwe m 2mm cs ACEClassNalzs P Data Structures amp Typing Numeric types are generalized Could specify precision amp range for reals Floating point Fixed point dollars etc Compilers can decide how many bits were needed for a given range amp precision Constructors from Pascal Records arrays enumerators pointers m 2mm cs ACEClassNalzs P Types Name Equivalence not Structural Subtypes Subranges compatible with base types Derived types not compatible with base types Both use operations etc from the base type But you can assign amp operate on subrange types amp the base types You can t assign a base type to a derived type or vice versa You can do an explicit cast or conversion m 2mm cs ACEClassNalzs P 29 Subranges Implemented by constraints 9subtype Index is Integer range 1100 Types have attributes Index Range Index First Index Last o This solves Pascal s problem of passing different sized arrays as parameters Fa 2mm cs 403 class Nam Name Structures Basic names 9 Pascal Subprogram parameters are more flexible You can specify In Out or InOut and let the compiler decide how to pass copy or reference You can specify default values for parameters Ifthe call is made We an actual parameter You can specify actualformal parameter correspondence by position like Algol or by name Fooparam5 gt 47 param3 gt12param18 gt a Fa 2mm cs 403 class Nam Problems with Global Variables 0 Side effects a global variable can be changed without being in the parameter list so you don t see the change when debugging Algol had no private variables 0 Vulnerability declaring a local x would hide any nonlocal x 0 Overlapping data definitions can t be kept separate See Fig 74 p 262 Fa 2mm cs 403 class Nam P 12 As Algol deprecated goto so Ada deprecated global variables 0 David Parnas promoted the idea of Information Hidingquot User should have all the information needed to use a module but nothing more mpementor should have all the information needed to write the module and nothing more m 2mm cs ACEClassNalzs P l Information Hiding 0 Packages support information hiding Two parts Package Specification all the public functions and variables if any but nothing else Package Body implementation the actual code variables etc 0 Name access is by mutual consent mpementor makes some names public User can import all names orjust a subset m 2mm cs ACEClassNalzs P 14 Packages Several roles Most Ada libraries are packages Packages allow shared data areas If you don t use the package you don t have access to the data 9 less bugs ADTs can be packages package Stack is Packages can have generic types Stack could be instantiated as a stack of Integers Floats Records Stack could be instantiated with a size m 2mm cs ACEClassNalzs P 215 Generic Packages 0 Writing the compiler to instantiate generics is hard Duhll Not very efficient 0 If we instantiate Stack for two different types say integers amp records 9 0 We have two different Push and Pop procedures one for each type 0 How does the compiler know which one to call It can be done but it makes the compiler do more work an 2mm cs 403 Class Names P 1 Overloaded Operators Overloaded procedures can complicate writing amp identifying operators 0 Should int realquot do the same thing as real intquot All we really did was swap the parameter types To implement this package you have to write both operators If you don t write both one operator either won t work Booml or one of the arguments may be coerced in a way you don t expect an 2mm cs 403 Class Names End of class Read Chapter 8 More Ada for next Tuesday chapter 14 Principles of Language Design for next Thursday Work on Paper assignment Check web page for updated grades m 2mm cs 403st P 218
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'