Overview: Lecture 6: Dolores Zage. What is a program? n Operations that are to be applied to certain data in a certain sequence (definition holds for.

Slides:



Advertisements
Similar presentations
Data Structures Static and Dynamic.
Advertisements

Chapter 6 Type Checking. The compiler should report an error if an operator is applied to an incompatible operand. Type checking can be performed without.
Names and Bindings.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
CSE 341, Winter Type Systems Terms to learn about types: –Type –Type system –Statically typed language –Dynamically typed language –Type error –Strongly.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Chapter Four Data Types Pratt 2 Data Objects A run-time grouping of one or more pieces of data in a virtual machine a container for data it can be –system.
Type Checking.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Names, Bindings, Type Checking, and Scopes
ISBN Chapter 6 Data Types: Structured types.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Type Checking Strong Typing Type Compatibility.
G. Levine Chapter 6 Chapter 6 Encapsulation –Why do we want encapsulation? Programmer friendliness- programmer need not know about these details –Easier.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Run time vs. Compile time
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Elementary Data Types Scalar Data Types Numerical Data Types Other
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
MT311 Java Application Programming and Programming Languages Li Tak Sing ( 李德成 )
Guided Notes Ch. 5 Basic Semantics Ch. 6 Data Types PHP Fundamentals Lecture Notes from both Louden and Sebesta Review questions.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
March 12, ICE 1341 – Programming Languages (Lecture #6) In-Young Ko Programming Languages (ICE 1341) Lecture #6 Programming Languages (ICE 1341)
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 Type Checking Type checking ensures that the operands and the operator are of compatible types Generalized to include subprograms and assignments Compatible.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
1 Dynamic Memory Allocation –The need –malloc/free –Memory Leaks –Dangling Pointers and Garbage Collection Today’s Material.
Types(1). Lecture 52 Type(1)  A type is a collection of values and operations on those values. Integer type  values..., -2, -1, 0, 1, 2,...  operations.
Object-Oriented Programming Chapter Chapter
Structure of Programming Languages Names, Bindings, Type Checking, and Scopes.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
CS 330 Programming Languages 10 / 23 / 2007 Instructor: Michael Eckmann.
Names, Scope, and Bindings Programming Languages and Paradigms.
Names, Bindings, Type Checking and Scopes. Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Type Equivalence.
Chapter 5 Names, Bindings, Type Checking CSCE 343.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Computer Applications in Business
Polymorphism in Methods
Data Types In Text: Chapter 6.
Names and Attributes Names are a key programming language feature
CS 326 Programming Languages, Concepts and Implementation
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Type Checking, and Scopes
Compiler Construction (CS-636)
CS 326 Programming Languages, Concepts and Implementation
Naming and Binding A computer system is merely a bunch of resources that are glued together with names Thus, much of system design is merely making choices.
The Procedure Abstraction Part I: Basics
Subprograms and Programmer Defined Data Type
Names and Binding In Text: Chapter 5.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
WJEC GCSE Computer Science
Presentation transcript:

Overview: Lecture 6: Dolores Zage

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

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!

Type Checking n Computer hardware data storage representations usually include no type information n ….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

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

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

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

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

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?

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!

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

Other PL sites n Hotprog.com Hotprog.com

Weak - Safe Weak Safe All Programs There are weak programs that are safe (type errors are caught at run time)