This document discusses key concepts related to variables in programming languages including names, bindings, scopes, and lifetimes. It covers different types of variables such as static, stack dynamic, and heap dynamic variables. It also compares static and dynamic scoping models and how they determine variable visibility. The referencing environment is defined as the collection of all visible variables for a given statement.
This presentation will introduce you to programming languages that support different programming paradigms and to give you the knowledge of basic concepts and techniques that will allow them to differentiate between various programming paradigms.
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
Introduction to Python:
The basic elements of Python, Objects, expressions and numerical Types, Variables and assignments, IDLE, Branching programs, Strings and Input, Iteration
Structured Types, Mutability and Higher-order Functions:
Tuples, Lists and Mutability, Functions as Objects, Strings, Tuples and Lists, Dictionaries
This presentation will introduce you to programming languages that support different programming paradigms and to give you the knowledge of basic concepts and techniques that will allow them to differentiate between various programming paradigms.
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
Introduction to Python:
The basic elements of Python, Objects, expressions and numerical Types, Variables and assignments, IDLE, Branching programs, Strings and Input, Iteration
Structured Types, Mutability and Higher-order Functions:
Tuples, Lists and Mutability, Functions as Objects, Strings, Tuples and Lists, Dictionaries
Decision making:
In CSharp, various types of decision making statements are available such as if..else, if..else..if, switch etc. Each statement is used to evaluate the specific test. If tests are determined to be true, specific statement will be execued for example : if(a > b) statement1 else statement2. Sometimes when develpoing program that requires to take the decision to execute specific part of program, decision making statement helps to do so.
Switch Case
In CSharp switch acts like a multiple if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true. If no matching case found, it executes the default case. The break(optional) statements with case indicate to the interpreter to end the particular case.
This presentation is all about Static and Dynamic rule used in the programming , It is important to understand the scope of variable and how program is processed inside the memory.
I hope this (.ppt) will be helpful to students studying Computer Science :)
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
If you're absolutely new to Python, and to programming in general, this is the place to start!
Here's the breakdown: by the end of this workshop, you'll have Python downloaded onto your personal machine; have a general idea of what Python can help you do; be pointed in the direction of some excellent practice materials; and have a basic understanding of the syntax of the language.
Please don't forget to bring your laptop!
Audience: "Python 101" is geared toward individuals who are new to programming. If you've had some programming experience (shell scripting, MATLAB, Ruby, etc.), then you'll probably want to check out the more intermediate workshop, "Python 101++".
Programming Language
As we know, to communicate with a person, we need a specific language, similarly to communicate with computers, programmers also need a language is called Programming language.
Before learning the programming language, let's understand what is language?
What is Language?
Language is a mode of communication that is used to share ideas, opinions with each other. For example, if we want to teach someone, we need a language that is understandable by both communicators.
What is a Programming Language?
A programming language is a computer language that is used by programmers (developers) to communicate with computers. It is a set of instructions written in any specific language ( C, C++, Java, Python) to perform a specific task.
A programming language is mainly used to develop desktop applications, websites, and mobile applications.
Types of programming language
1. Low-level programming language
Low-level language is machine-dependent (0s and 1s) programming language. The processor runs low- level programs directly without the need of a compiler or interpreter, so the programs written in low-level language can be run very fast.
Low-level language is further divided into two parts -
i. Machine Language
Machine language is a type of low-level programming language. It is also called as machine code or object code. Machine language is easier to read because it is normally displayed in binary or hexadecimal form (base 16) form. It does not require a translator to convert the programs because computers directly understand the machine language programs.
The advantage of machine language is that it helps the programmer to execute the programs faster than the high-level programming language.
ii. Assembly Language
Assembly language (ASM) is also a type of low-level programming language that is designed for specific processors. It represents the set of instructions in a symbolic and human-understandable form. It uses an assembler to convert the assembly language to machine language.
For college going students, employees of a company or for a common man, bus is the most comprehensive and affordable mode of transport. The use of bus for transport reduces private vehicle usage and thus reduces fuel consumption. It also curbs traffic congestion. The user usually wants to know the accurate arrival time of the bus. Long time waiting at the bus stops discourage the use of buses. Also many unpredictable factors delay the schedule of a bus like harsh weather situation, traffic conditions etc. Towards this aim of reducing this problem, we are proposing a project which will assist the bus travellers in predicting bus timings. The system described uses DriverSideApp, ClientSideApp and a server.
In this project, we propose an innovative method for predicting the bus information. No specific device is required for this purpose. Our sole objective is to build a application that will help student to access the current location of the bus. Moving forward our application focus on to providing them more convenience with bus schedules, bus location information so that they may not get delayed. . Further, the recent advent and popularity of Android technology motivates us to create an Android application for the same.
Decision making:
In CSharp, various types of decision making statements are available such as if..else, if..else..if, switch etc. Each statement is used to evaluate the specific test. If tests are determined to be true, specific statement will be execued for example : if(a > b) statement1 else statement2. Sometimes when develpoing program that requires to take the decision to execute specific part of program, decision making statement helps to do so.
Switch Case
In CSharp switch acts like a multiple if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true. If no matching case found, it executes the default case. The break(optional) statements with case indicate to the interpreter to end the particular case.
This presentation is all about Static and Dynamic rule used in the programming , It is important to understand the scope of variable and how program is processed inside the memory.
I hope this (.ppt) will be helpful to students studying Computer Science :)
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
If you're absolutely new to Python, and to programming in general, this is the place to start!
Here's the breakdown: by the end of this workshop, you'll have Python downloaded onto your personal machine; have a general idea of what Python can help you do; be pointed in the direction of some excellent practice materials; and have a basic understanding of the syntax of the language.
Please don't forget to bring your laptop!
Audience: "Python 101" is geared toward individuals who are new to programming. If you've had some programming experience (shell scripting, MATLAB, Ruby, etc.), then you'll probably want to check out the more intermediate workshop, "Python 101++".
Programming Language
As we know, to communicate with a person, we need a specific language, similarly to communicate with computers, programmers also need a language is called Programming language.
Before learning the programming language, let's understand what is language?
What is Language?
Language is a mode of communication that is used to share ideas, opinions with each other. For example, if we want to teach someone, we need a language that is understandable by both communicators.
What is a Programming Language?
A programming language is a computer language that is used by programmers (developers) to communicate with computers. It is a set of instructions written in any specific language ( C, C++, Java, Python) to perform a specific task.
A programming language is mainly used to develop desktop applications, websites, and mobile applications.
Types of programming language
1. Low-level programming language
Low-level language is machine-dependent (0s and 1s) programming language. The processor runs low- level programs directly without the need of a compiler or interpreter, so the programs written in low-level language can be run very fast.
Low-level language is further divided into two parts -
i. Machine Language
Machine language is a type of low-level programming language. It is also called as machine code or object code. Machine language is easier to read because it is normally displayed in binary or hexadecimal form (base 16) form. It does not require a translator to convert the programs because computers directly understand the machine language programs.
The advantage of machine language is that it helps the programmer to execute the programs faster than the high-level programming language.
ii. Assembly Language
Assembly language (ASM) is also a type of low-level programming language that is designed for specific processors. It represents the set of instructions in a symbolic and human-understandable form. It uses an assembler to convert the assembly language to machine language.
For college going students, employees of a company or for a common man, bus is the most comprehensive and affordable mode of transport. The use of bus for transport reduces private vehicle usage and thus reduces fuel consumption. It also curbs traffic congestion. The user usually wants to know the accurate arrival time of the bus. Long time waiting at the bus stops discourage the use of buses. Also many unpredictable factors delay the schedule of a bus like harsh weather situation, traffic conditions etc. Towards this aim of reducing this problem, we are proposing a project which will assist the bus travellers in predicting bus timings. The system described uses DriverSideApp, ClientSideApp and a server.
In this project, we propose an innovative method for predicting the bus information. No specific device is required for this purpose. Our sole objective is to build a application that will help student to access the current location of the bus. Moving forward our application focus on to providing them more convenience with bus schedules, bus location information so that they may not get delayed. . Further, the recent advent and popularity of Android technology motivates us to create an Android application for the same.
“Bus Tracking Application” is an application for Smart phones that works on Android Operating system. This application uses the GPS function. This application at a specific pickup point will send the current location of the bus to students when they request. This app generate predictions of bus arrivals at stops along the route. This application uses a variety of technologies to track the locations of buses in real time
“Bus Tracking Application” is an application for Smart phones that works on Android Operating system.
This application uses the GPS function.
This application at a specific pickup point will send the current location of the bus to students when they request.
This app generate predictions of bus arrivals at stops along the route.
This application uses a variety of technologies to track the locations of buses in real time.
Esoft Metro Campus - Programming with C++
(Template - Virtusa Corporate)
Contents:
Overview of C++ Language
C++ Program Structure
C++ Basic Syntax
Primitive Built-in types in C++
Variable types
typedef Declarations
Enumerated Types
Variable Scope
Constants/Literals
Storage Classes
Operators
Control Constructs
Functions
Math Operations in C++
Arrays
Multi-dimensional Arrays
Strings
C++ Pointers
References
Date and Time
Structures
Basic Input / Output
Classes and Objects
Inheritance
Overloading
Polymorphism
Interfaces
Files and Streams
Exception Handling
Dynamic Memory
Namespaces
Templates
Preprocessor
Multithreading
learn JAVA at ASIT with a placement assistance.ASIT Education
AMC Squarelearning Bangalore is the best training institute for a career development. it had students from various parts of the country and even few were from West African countries.
You’re finally doing TDD, but your past mistakes are catching up with you. No matter what you do, you can’t get rid of the gaping black holes caused by your legacy code.
In this presentation, we learn about the causes of legacy code and the reasons it is so difficult to work with. Then we discuss various techniques to test untestable code, revive and simplify incomprehensible code, redesign stable yet untested code, and repair that rift we created in the time-space continuum.
Aim of this presentation is not to make you masters in Java 8 Concurrency, but to help you guide towards that goal. Sometimes it helps just to know that there is some API that might be suitable for a particular situation. Make use of the pointers given to search more and learn more on those topics. Refer to books, Java API Documentation, Blogs etc. to learn more. Examples and demos for all cases discussed will be added to my blog www.javajee.com.
How to build a news website use CMS wordpressbaran19901990
This tutorial wil show you, how to build a news website use CMS Wordpress step by step. From basic to advantage. I think that this tutorial is amazing and very basic for newbie.
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
Wireless communication involves the transmission of information over a distance without the help of wires, cables or any other forms of electrical conductors.
Wireless communication is a broad term that incorporates all procedures and forms of connecting and communicating between two or more devices using a wireless signal through wireless communication technologies and devices.
Features of Wireless Communication
The evolution of wireless technology has brought many advancements with its effective features.
The transmitted distance can be anywhere between a few meters (for example, a television's remote control) and thousands of kilometers (for example, radio communication).
Wireless communication can be used for cellular telephony, wireless access to the internet, wireless home networking, and so on.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
Italy Agriculture Equipment Market Outlook to 2027harveenkaur52
Agriculture and Animal Care
Ken Research has an expertise in Agriculture and Animal Care sector and offer vast collection of information related to all major aspects such as Agriculture equipment, Crop Protection, Seed, Agriculture Chemical, Fertilizers, Protected Cultivators, Palm Oil, Hybrid Seed, Animal Feed additives and many more.
Our continuous study and findings in agriculture sector provide better insights to companies dealing with related product and services, government and agriculture associations, researchers and students to well understand the present and expected scenario.
Our Animal care category provides solutions on Animal Healthcare and related products and services, including, animal feed additives, vaccination
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
This 7-second Brain Wave Ritual Attracts Money To You.!nirahealhty
Discover the power of a simple 7-second brain wave ritual that can attract wealth and abundance into your life. By tapping into specific brain frequencies, this technique helps you manifest financial success effortlessly. Ready to transform your financial future? Try this powerful ritual and start attracting money today!
guildmasters guide to ravnica Dungeons & Dragons 5...
Subprogram
1. Chapter 5: Names, Bindings, and Scopes
Principles of Programming Languages
2. Contents
•Names
•Variables
•The Concept of Binding
•Scope and Lifetime
•Referencing Environments
•Named Constants
3. Introduction
•Imperative languages are abstractions of von Neumann architecture
–Memory variables
•Variables characterized by attributes, among of them is type
•Scope and lifetime of variables are important issues when designing type
5. Names (Identifiers)
•Design issues for names:
–Are names case sensitive?
–Are special words reserved words or keywords?
6. Name Forms
•Length
–If too short, they cannot be connotative
–Language examples:
•FORTRAN I: maximum 6
•FORTRAN 95: maximum 31
•C89: unlimited but first 31 is significant
•Ada, Java, C#: no limit, and all are significant
•C++: no limit, but implementers often impose one
7. Name Forms
•Most of languages: a letter followed by s string consisting of letters, digits, or underscore
•Special forms:
–PHP: variables begin with $
–Perl: special beginning characters denote type $, @, %
–Ruby: @ instance variable, @@ class variable
8. Name Forms
•Case sensitivity
–Many languages, including C-based languages, are case sensitive
–Disadvantage:
•readability (names that look alike are different)
•writability: C++ and Java’s predefined names are mixed case (e.g. IndexOutOfBoundsException)
9. Special Words
•Special words
–An aid to readability; used to delimit or separate statement clauses
–A keyword is a word that is special only in certain contexts, e.g., in Fortran
– A reserved word is a special word that cannot be used as a user-defined name
–Which one is better? …, but…
10. Variables
•A variable is an abstraction of a memory cell
•Variables can be characterized as 6 attributes:
–Name
–Address
–Type
–Value
–Lifetime
–Scope
11. Variables Attributes
•Name - not all variables have them
•Address - the memory address with which it is associated
–A variable may have different addresses at different times during execution
–l-value
–Two variable names can be used to access the same memory: aliases
•created via pointers, reference variables, subprogram parameters
•harmful to readability
12. Variables Attributes
•Type - determines the range of values of variables and the set of operations that are defined for values of that type
•Value - the contents of the memory cell(s) associated with the variable
–Memory cell here is abstract cell, not physical cell
–r-value
13. The Concept of Binding
•A binding is an association
–an attribute and an entity
–an operation and a symbol
•Binding time is the time at which a binding takes place.
14. Possible Binding Times
•Language design time -- bind operator symbols to operations
•Language implementation time -- data type is bound to range of possible values
•Compile time -- bind a variable to a data type in Java
•Load time -- bind a variable to a memory cell for C static variable
•Link time -- call to library subprogram to its code
•Runtime -- bind a non-static local variable to a memory cell
15. Example
•Consider the C assignment statement
count = count + 5;
–Type of count
–Set of possible values of count
–Meaning of +
–Internal representation of 5
–Value of count
16. Static and Dynamic Binding
•A binding is static if it first occurs before run time and remains unchanged throughout program execution.
•A binding is dynamic if it first occurs during execution or can change during execution of the program
17. Binding
•Let’s discuss two types of binding:
–Type binding: variable to data type
–Storage binding: variable to its address
18. Type Binding
•How is a type specified?
•When does the binding take place?
•If static, the type may be specified by either an explicit or an implicit declaration
19. Explicit/Implicit Declaration
•An explicit declaration is a program statement used for declaring the types of variables
•An implicit declaration is a default mechanism for specifying types of variables
–Ex.
•FORTRAN: I-N: Integer, others real
•Perl: $a: scalar, @a: array
–Advantage: writability
–Disadvantage: reliability (less trouble with Perl)
20. Dynamic Type Binding
•JavaScript and PHP
•Specified through an assignment statement e.g., JavaScript
list = [2, 4.33, 6, 8];
list = 17.3;
–Advantage: flexibility (generic program units)
–Disadvantages:
•High cost (dynamic type checking and interpretation)
•Type error detection by the compiler is difficult
21. Type Inference
•Ex. ML
fun circumf(r) = 3.14159 * r * r;
fun square(x) = x * x;
fun square( x : real) = x * x;
fun square(x) = (x : real) * x;
fun square(x) = x * (x : real);
fun square(x) : real = x * x;
22. Storage Binding & Lifetime
•Storage binding
–Allocation - getting a cell from some pool of available cells
–Deallocation - putting a cell back into the pool
•The lifetime of a variable is the time during which it is bound to a particular memory cell
23. Categories of Variables by Lifetimes
•Static--bound to memory cells before execution begins and remains bound to the same memory cell throughout execution, e.g., all FORTRAN 77 variables, C static variables
•Advantages: efficiency (direct addressing), history-sensitive subprogram support
•Disadvantage: lack of flexibility (no recursion)
24. Categories of Variables by Lifetimes
•Stack-dynamic--Storage bindings are created for variables when their declaration statements are elaborated.
–If scalar, all attributes except storage are statically bound
•local variables in C subprograms and Java methods
•Advantage: allows recursion; conserves storage
•Disadvantages:
–Overhead of allocation and deallocation
–Subprograms cannot be history sensitive
–Inefficient references (indirect addressing)
25. Categories of Variables by Lifetimes
•Explicit heap-dynamic -- Allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution
•Referenced only through pointers or references, e.g. dynamic objects in C++ (via new and delete), all objects in Java
•Advantage: provides for dynamic storage management
•Disadvantage: inefficient and unreliable
26. Categories of Variables by Lifetimes
•Implicit heap-dynamic--Allocation and deallocation caused by assignment statements
–all variables in APL; all strings and arrays in Perl and JavaScript
•Advantage: flexibility
•Disadvantages:
–Inefficient, because all attributes are dynamic
–Loss of error detection
27. Variable Attributes: Scope
•The scope of a variable is the range of statements over which it is visible
•The scope rules of a language determine how references to names are associated with variables
•Local vs. nonlocal variables
28. Static Scope
•Based on program text
•To connect a name reference to a variable, you (or the compiler) must find the declaration
•Search process: search declarations, first locally, then in increasingly larger enclosing scopes, until one is found for the given name
•Enclosing static scopes (to a specific scope) are called its static ancestors; the nearest static ancestor is called a static parent
29. Scope (continued)
•Variables can be hidden from a unit by having a "closer" variable with the same name
•C++ and Ada allow access to these "hidden" variables
–In Ada: unit.name
–In C++: class_name::name
30. Example -- Ada
procedure Big is
X : Integer;
procedure Sub1 is
X : Integer;
begin -- of Sub1
...
end; -- of Sub1
procedure Sub2 is
begin -- of Sub2
... X ...
end; -- of Sub2
begin -- of Big
...
end; -- of Big
31. Blocks
•A method of creating static scopes inside program units--from ALGOL 60
•Examples: C or C++ (not Java or C#)
void sub() {
int count;
...
while ( … ) {
int count;
count++;
...
}
...
}
•Global variables are defined in outermost block
32. var A, B, C: real; //1
procedure Sub1 (A: real); //2
var D: real;
procedure Sub2 (C: real);
var D: real;
begin
… C:= C+B; …
end;
begin
… Sub2(B); …
end;
begin
… Sub1(A); …
end.
Declaration
Scope
A:real //1
Main
B:real //1
Main,Sub1,Sub2
C:real//1
Main,Sub1
A:real //2
Sub1,Sub2
…
33. •Assume MAIN calls A and B
A calls C and D
B calls A and E
MAIN
MAIN
E
A
C
D
B
A
B C
D E
Evaluation of Static Scoping
35. Static Scope (continued)
•Suppose the spec is changed so that D must now access some data in B
•Solutions:
–Put D in B (but then C can no longer call it and D cannot access A's variables)
–Move the data from B that D needs to MAIN (but then all procedures can access them)
•Same problem for procedure access
•Overall: static scoping often encourages many globals
36. Dynamic Scope
•Based on calling sequences of program units, not their textual layout
•References to variables are connected to declarations by searching back through the chain of subprogram calls that forced execution to this point
•APL, SNOBOL4, early LISP (Perl, Common LISP)
37. Example
procedure Big is
X : Integer;
procedure Sub1 is
X : Integer;
begin -- of Sub1
...
end; -- of Sub1
procedure Sub2 is
begin -- of Sub2
... X ...
end; -- of Sub2
begin -- of Big
...
end; -- of Big
Big --> Sub1 --> Sub2
Big --> Sub2
38. Evaluation
•Disadvantages:
–Local variables are not private anymore, less reliable
–Cannot statically type check
–Readability
–Reading overhead
•Advantage:
–No need to pass parameters
39. Scope and Lifetime
•Scope and lifetime are sometimes closely related, but are different concepts
•Examples:
–A variable declared in a Java method that contains no method calls
–A variable declared in C/C++ function with static specifier
–Subprogram calls
40. Referencing Environments
•The referencing environment of a statement is the collection of all names that are visible in the statement
•In a static-scoped language, it is the local variables plus all of the visible variables in all of the enclosing scopes
41. procedure Example is
A, B : Integer;
...
procedure Sub1 is
X, Y : Integer;
begin -- of Sub1
... <-------------------------- 1
end; -- of Sub1
procedure Sub2 is
X : Integer;
...
procedure Sub3 is
X: Integer;
begin -- of Sub3
... <----------------------- 2
end; -- of Sub3
begin -- of Sub2
... <------------------------ 3
end; -- of Sub2
begin -- of Example
... <-------------------------- 4
end. -- of Example
42. Referencing Environment
•A subprogram is active if its execution has begun but has not yet terminated
•In a dynamic-scoped language, the referencing environment is the local variables plus all visible variables in all active subprograms
43. void sub1() {
int a, b;
... <---------------- 1
} /* end of sub1 */
void sub2() {
int b, c;
... <-------------- 2
sub1;
} /* end of sub2 */
void main() {
int c, d;
... <---------------- 3
sub2();
} /* end of main */
main --> sub2 --> sub1
44. Named Constants
•A named constant is a variable that is bound to a value only when it is bound to storage
•Advantages: readability and modifiability
•Used to parameterize programs
•The binding of values to named constants can be either static (called manifest constants) or dynamic
•Languages:
–FORTRAN 90: constant-valued expressions
–Ada, C++, and Java: expressions of any kind
45. Variable Initialization
•The binding of a variable to a value at the time it is bound to storage is called initialization
•Initialization is often done on the declaration statement, e.g., in Java
int sum = 0;
46. Summary
•Case sensitivity and the relationship of names to special words represent design issues of names
•Variables are characterized by the sextuples: name, address, value, type, lifetime, scope
•Binding is the association of attributes with program entities
•Scalar variables are categorized as: static, stack dynamic, explicit heap dynamic, implicit heap dynamic
47. Summary (continued)
•Static scoping provides a simple, reliable, and efficient method of allowing visibility of nonlocal variables in subprograms
•Dynamic scoping provides more flexibility than static scoping but at expense of readability, reliability, and efficiency
•Referencing environment of a statement is the collection of all the variables that are visible to that statement