Download presentation
Presentation is loading. Please wait.
Published byMelanie Wilkerson Modified over 8 years ago
1
Overview: Lecture 6: Dolores Zage
2
What is a program? n Operations that are to be applied to certain data in a certain sequence (definition holds for all languages) n Basic differences among languages exist in: u types of data allowed u types of operations available u mechanisms for controlling the sequence of the operations applied to the data
3
Focus: n Chapter 4 concentrates data, types (highlighting imperative languages) n Chapter 5 procedures (extensions to the usual built in types defined by the programmer) encapsulation (a higher level abstraction or representation) actually defining the syntax and operations on this construct!
4
Type Checking n Computer hardware data storage representations usually include no type information n 1110000101010….111 n Can you tell if this is an integer, real, sequence of chars, an instruction? n Common error in assembly languages is to invoke an operation such as integer addition on arguments of the wrong type
5
Type Checking n These errors are difficult to locate because the operation works since the result (usually meaningless) is just a bit string. n A major advantage of using a higher level language is that the language implementation can provide type checking. n Type checking means that each operation executed by a program receives the proper number of arguments of the proper data type
6
Dynamic type checking n At run time n done immediately before operation n usually implemented by storing a type tag in each data object n each operation must attach the appropriate type tags to the results n done in languages that do not require declarations n dynamic types advantage is flexibility in design - programmer is “freed” from most concerns about data types
7
Disadvantages of Dynamic Type Checking n Errors lurk in the program until they are executed (in large programs can be several hours of execution) n not all program paths are executed n type information can be substantial n implemented in software and each operation must be checked before -> speed of execution is likely to be greatly reduced
8
Static Type Checking n Eliminate or minimize dynamic checking-> perform type checking at compile time. n Collect info in symbol table n In most languages, static type checking is not possible for some constructs u dynamic type checking u leaving the operations unchecked
9
Typing n Strong - all type errors can be detected statically (strongly typed) n Text book definition - so only one language can fit in this category - ML n Notice that when a language has either arrays, enumeration, subranges -> it cannot be strong n How do you know that A[1+number] will be in the range of your array? n or that Monday + Sunday will still be part of the enumerated set?
10
Typing n So the question is what will you give up to get a strongly typed language !(or to get a safe run-time program) n Another question you may have … How does a strongly typed language do any operations? Every “overflow” condition is defined in the language. n There is much confusion on strong typing. You either catch ALL errors or you are weak. PERIOD. But I guess there are scales of weakness.. n So there is much confusion out in the “PUBLIC”. And there is a difference between strong type and structured type!
11
Typing n what-is definition what-is definition F by what-is.com n what is a “Merry Strongly-Typed Christmas” n Garbage Collection for Strongly-Typed Languages Garbage Collection for Strongly-Typed Languages n typing and binding, typing and binding, F page by Carl Erickson n PERL PERL for slow connections, I simply downloaded the page and made a local copy
12
Other PL sites n Hotprog.com Hotprog.com
13
Weak - Safe Weak Safe All Programs There are weak programs that are safe (type errors are caught at run time)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.