SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Topics on Imperative Languages
Variables: names, bindings, type, scope Sebesta Chapter 5
Data Types Sebesta Chapter 6
Expressions Sebesta Chapter 7
Control Statements Sebesta Chapter 8
Subprograms: Concepts & Implementation Sebesta Chapters 9 & 10
Abstract Data Types Sebesta Chapter 11
Exception Handling Sebesta Chapter 14
Object Oriented languages Sebesta Chapter 12
CSC3403 Comparative Programming Languages Variables & Identifiers 1
Variable concepts
• Imperative languages map simply to von Neuman architecture
(linear memory, CPU, sequential execution)
• Variables correspond to memory cell(s)
– integers, floats (direct support for operations)
– record or structure
– (variables may be optimised to registers)
• Variable attributes
Œ name  value
 type  lifetime
Ž location ‘ scope
• related issues: named constants, initialisation
CSC3403 Comparative Programming Languages Variables & Identifiers 2
Names
• synonym: identifiers parent(amy,cathy). parent(bill,cathy).
• applies also to names of functions, constants, types, etc.
• issues
– Maximum length
∗ limited: truncate or error if identifer too long
∗ unlimited: storage/implementation considerations
(This is really an implementation issue.)
– valid chars—typically: 0-9 a-z A-Z _~; first char non-numeric
– case sensitive?
– special words
∗ keywords — depend on context ⇒ dangerous (see next...)
∗ reserved words—e.g. if then return
∗ predefined names (system/library definitions—may be redefined)
writeln printf cout map fold
CSC3403 Comparative Programming Languages Variables & Identifiers 3
Example: Keywords considered dangerous
1962: NASA Mariner 1 Venus probe lost
• Early FORTRAN compilers implemented keywords
• Early FORTRAN compilers ignored spaces
• Programmer meant to write:
DO 5 I = 1, 3
...body of loop...
5 CONTINUE
• Problem: period instead of comma
DO 5 I = 1. 3
which is interpreted as the assignment:
DO5I = 1.3
• Result: loop not executed ⇒ program fails ⇒ Mariner 1 lost
CSC3403 Comparative Programming Languages Variables & Identifiers 4
Name space
• identifiers can be partitioned into classes: e.g. variables, types, record
names, field names, enumerated constants, module names, etc...
• where ambiguity cannot occur, only require identifiers to be unique within
their name space
• a name space is defined by the class(es) of identifier(s) it contains
• E.g. allow field names and variable names to occupy separate name spaces,
but variables and constants should occupy the same name space.
struct s { int a; int s;};
int main(){ struct s s; s.s = 1; }
• Note: Modern OO languages also implement explicit programmer
specified namespaces; this is different from the language-defined
namespaces discussed here.
CSC3403 Comparative Programming Languages Variables & Identifiers 5
Variable location
• Each variable instance has a unique start address
• It will typically occupy a range of addresses
(Very few data types can be held in just 1 byte.)
• A variable instance is defined by its
1. name
2. declaration site — which subprogram/block
3. current block instance (only required if recursive call)
CSC3403 Comparative Programming Languages Variables & Identifiers 6
Example of variable instances
There are 3 declarations of var in this program, but as many as 9 instances!
#include <stdio.h>
int var; /* 1: global variable */
int f1(){
int var; /* 2: local variable */
var = 42;
}
int f2(int var){ /* 3: parameter == local var */
if (var==0) return 1;
else return var * f2(var-1);
}
main(){
f1();
var = f2(6);
printf("%dn", var);
}
CSC3403 Comparative Programming Languages Variables & Identifiers 7
Variables Aliases
alias: 1 location but >1 name or access method
• explicit: Fortran EQUIVALENCE, C union
struct symtabEntry{ char *name;
int type;
union { int ival;
float fval;
char *sval;
} value;
}
Memory layout:
0 4 8 12
ival
name type fval
sval
CSC3403 Comparative Programming Languages Variables & Identifiers 8
Variables Aliases ....
• indirect: via pointers
int x,*p,*q;
p=&x;
q=&x;
*p=42;
printf("meaning of life = %dn", *q);
• indirect: call-by-reference parameters
void f(int *a, int *b) { *a++; *b++; }
...
f(&x, &x);
...
Comments
• Aliasing is a bad idea; reduces program readability (but variant records
can be useful in rare system programming applications)
• Better dynamic memory systems and abundant computer memory has
reduced/removed the need for aliasing
CSC3403 Comparative Programming Languages Variables & Identifiers 9
Variable type
A variable’s type defines (for language-specified types):
• the range of values that the variable can store (implementation dependent)
• the physical storage requirements (implementation dependent)
• the set of legal operations on the variable (language defined)
Variable value
• each variable instance has a value
• may be automatically initialised (see later)
• a value is contained in set of contiguous locations — called a cell
• r-value is value (contents of cell)
• l-value is address (location of cell)
CSC3403 Comparative Programming Languages Variables & Identifiers 10
Lifetime & Storage
• when is a memory cell allocated?
allocation ≡ location binding
• when is a memory cell deallocated?
• lifetime is time from allocation to deallocation (binding to unbinding)
• 4 classes of variable
– static variables
– stack-dynamic variables (automatic)
– explicit dynamic variables
– implicit dynamic variables
CSC3403 Comparative Programming Languages Variables & Identifiers 11
Static variables
• allocated before run time (usually link or load time)
• executable file contains space for static variables.
• the binding exists for entire lifetime of the program
 easy  cheap to access — compiler can compute the address at compile
time
 handy for global variables which are used throughout program
 useful for subprogram local variables (e.g. C static) when history is
required but variable is only needed in subprogram
# static parameters preclude recursion
CSC3403 Comparative Programming Languages Variables  Identifiers 12
Stack-dynamic variables
• allocated when code containing declaration is executed
• elaboration or instantiation is the name of the binding process
• variables are stored on the run-time stack (RTS)
• each block or subprogram invocation allocates a chunk of storage
(activation record instance) on the RTS
• subprogram exit ⇒ storage deallocation
# disadvantage: slower access — address must be calculated at run time
 advantages:
– enables recursion
– lower average memory usage
– smaller executables
– smaller libraries
CSC3403 Comparative Programming Languages Variables  Identifiers 13
Explicit dynamic variables
• explicitly created by programmer code
• not bound to variable — pointer variable holds address
struct stentry *stnode; // C++
stnode = new struct stentry; // allocate
...
delete stnode; // deallocate
• memory is allocated from the heap
• there is often a maximum heap size
 ideal for dynamic structures whose size is unknown at compile time (trees,
lists, etc.)
# opportunity for programmer errors (pointers—see later)
# cost of reference (indirect via pointer: 2 memory accesses)
# cost allocation/deallocation (heap magement).
CSC3403 Comparative Programming Languages Variables  Identifiers 14
Implicit dynamic variables
• employed by dynamic languages like APL, scripting languages
• storage allocated at assignment time
 advantage: flexible
# disadvantage: costly, poorer error detection
CSC3403 Comparative Programming Languages Variables  Identifiers 15
Scope
• variable scope: from where can it be referenced? (where is it visible?)
• scope rules define how to resolve references to non-local variables
(there may be  1 non-local variables of same name)
• a local variable is declared in current program unit
• each program unit introduces a new “scope”
– subprogram (a.k.a. procedure, function)
a named subprogram, usually with parameters
– block anonymous program unit
in C/C++: { .... }
– module named collection of definitions. (C++: namespace)
• two kinds
– static: compiler can resolve scope
– dynamic: scope resolved at run time
CSC3403 Comparative Programming Languages Variables  Identifiers 16
Static scoping rules
• to resolve reference to a variable
1. locate the variable’s declaration
2. retrieve variable’s attributes (type, address, etc)
• search algorithm
unit ⇐ referencing unit; found ⇐ False; done ⇐ False;
repeat
if variable declared in unit
then use this variable declaration
found ⇐ True; done ⇐ True
else if unit is not outermost
then unit ⇐ staticParent(unit)
else done ⇐ True
until done
CSC3403 Comparative Programming Languages Variables  Identifiers 17
Static scoping rules ....
Equivalent recursive definition:
A variable (say x) is visible within a referencing unit if it is either
• declared within that unit, or
• is visible from the static parent of the unit.
The referencing environment of a unit is the union of
• all identifiers declared local to the unit, and
• identifiers in the static parent’s referencing environment with names
different to those declared in this unit.
CSC3403 Comparative Programming Languages Variables  Identifiers 18
Nested scope
Program a b c d e
procedure main;
var a;
procedure sub1;
var b;
procedure sub2;
var c;
begin
end;
procedure sub3;
var d;
begin
end;
begin
end;
procedure sub4;
var e;
begin
end;
begin
end;
CSC3403 Comparative Programming Languages Variables  Identifiers 19
Hidden variables
Program xmain x1 x2 x3 x4
procedure main;
var x;
procedure sub1;
var x;
procedure sub2;
var x;
begin
end;
procedure sub3;
var x;
begin
end;
begin
end;
procedure sub4;
var x;
begin
end;
begin
end;
CSC3403 Comparative Programming Languages Variables  Identifiers 20
Static scoping issues
• Aim: to restrict access to vars/procs only to those units that need them,
thus avoiding the chance of accidental programming errors caused by
improper access.
• Non-nested function declarations (as in C) allow unrestricted calling of
functions. (With some exceptions—see later.)
• Nested declarations allow procedure calls only to
 Child procedure (but not granchild etc)
# Any ancestor procedure
• problems (see discussion Sebesta §5.8.3 )
– access not rescrictive enough (ancestors)
– overuse of global variables to provide resource sharing
– key question: How can two subprograms share local variables such
that no other subprograms can see them?
 modules, classes, namespaces (see later)
CSC3403 Comparative Programming Languages Variables  Identifiers 21
Case study: Scope in C
File Program x1 x2 x3 x4 f1,f3,f4 f2
p1.c int x; /* x1 */
main(){
int x; /* x2 */
x=2;
}
int f1(){
x=1;
}
p2.c static int x; /* x3 */
static int f2(){
x=3;
}
p3.c int f3(){
static int x; /* x4 */
x=4;
}
extern int x; /* x1 */
int f4(){
x=1;
}
CSC3403 Comparative Programming Languages Variables  Identifiers 22
Dynamic scope
• Apl, Snobol, early Lisp
• scope resolved at run time
• search dynamic parent chain
dynamic parent ≡ calling procedure
 callee automatic inherits caller’s locals
# cost of dynamic scope resolution
# difficulty of programming / debugging
Consider proc p() {a := a + 1; }
Q: Which instance of variable “a” is being updated?
A: Cannot tell from static structure of program!
You must trace through program execution to find out.
CSC3403 Comparative Programming Languages Variables  Identifiers 23
Binding concepts
• a binding is an association
– variable attribute ←→ value of attribute
– operation ←→ symbol
– executable code ←→ physical location
– conceptual/abstract ←→ concrete/value
• binding times (from early to late)
– language design (operator symbols)
– language implementation (range of data types)
– compile time (var ←→ type)
– link time (address of vars, functions in executable image file)
– load time (physical variable addresses)
– run time (dynamic variable addresses, DLL function addresses)
CSC3403 Comparative Programming Languages Variables  Identifiers 24
Static and Dynamic Binding
• static binding: bound before run time
• dynamic binding: bound during run time
• consider variable attributes
– name is always statically determined
– value is always dynamically bound (else it is a constant!)
– location and lifetime can safely be either static or dynamic
– type and scope can be either static or dynamic.
Static binding is safer and more readable for these attributes.
CSC3403 Comparative Programming Languages Variables  Identifiers 25
Type bindings — motivation
Q: Why do we need types?
A: At reference time, a variable must have a type so that either
1. on “read” (e.g. variable access), cell contents can be interpreted correctly
2. on “write” (e.g. assignment to variable), correct conversions are made
E.g. consider
int a,b; float c;
...
c = a + b;
Key design questions
• how is the type determined?
– explicit vs. implicit declarations
• when does variable–type binding occur?
– static vs. dynamic
CSC3403 Comparative Programming Languages Variables  Identifiers 26
How is (static) type specified/determined?
• explicit declarations
– mandatory (C++, Pascal, most modern languages)
– optional ([uncommon] KR C functions default to int)
• implicit declarations
– Fortran, Basic, PL/1
– Fortran: first letter convention: I J K L M N
– others: first use convention
– disadvantage: typographical errors undetected
coutner = counter + 1
• inference (implicit declaration supported by optional explicit declarations)
– ML, Miranda, Haskell, Gofer
– all types can be statically inferred
– comparison of declared vs inferred types finds errors
CSC3403 Comparative Programming Languages Variables  Identifiers 27
Dynamic type binding
• APL, shell languages (e.g. Perl, Tcl)
• automatic conversions required
 advantage: flexibility, generic subprograms possible, e.g.:
int inc(a) {return a+1;} // a can be any numeric type
# disadvantages
– typographical errors not caught (see previous example)
– cost of dynamic type inference
– interpreted implementions usually required
• Note: advanced languages (Ada, C++, Haskell) provide polymorphic
type-checked subprograms
– provides generic subprograms with static type checking
CSC3403 Comparative Programming Languages Variables  Identifiers 28
Typing concepts
• Type error A type error occurs when an operator (or function) is applied
to an operand (e.g. a variable, but in genaral any expression) whose type is
not compatible with the operator’s parameter type.
If this error is not detected by the language implementation system ⇒
program bug!
int i=1; double f,*p; p = (double *) i; *p = f;
• Type checking To check that an operator or subprogram is applied to
arguments of the correct type. (Assignment is considered a binary
operator).
• Compatible type Either a type which matches the operator’s definition or
a type which can be automatically converted, using language rules, into
the correct matching type.
• Coersion Automatic conversion of types.
CSC3403 Comparative Programming Languages Variables  Identifiers 29
Strong typing
Definition: All type errors in a program can be detected
• no imperative language is strongly typed
• typical problems: variant records, non-checked type casts
• many languages (e.g. Java, C#, Ada) are almost strongly typed
• modern functional languages are strongly typed (static typing)
• coercion weakens strong typing
Comment Strong typing is seen by most language researchers/designers as a
“good idea”, and most newer languages have very good type checking.
CSC3403 Comparative Programming Languages Variables  Identifiers 30
Type conversion examples
Consider “assignment” of a floating point to an integer.
C: coersion, type error
int i,j;
double a=999999999.5,
b=9999999999.5;
int main(){ i = a; j = b; printf(i=%d j=%dn,i,j);}
execution ⇒ i=999999999 j=-2147483648
Haskell: strong typing: explicit conversion + runtime check
Hugs :t truncate
truncate :: (RealFrac a, Integral b) = a - b
Hugs (truncate 999999999.5)::Int
999999999
Hugs (truncate 9999999999.5)::Int
Program error: arithmetic overflow
CSC3403 Comparative Programming Languages Variables  Identifiers 31
Type compatibility
• name type compatibility
– both varables appear in same declaration
or both variables declared with the same type name
– C++ uses name compatibility
main(){ //C++
struct point {int x,y;} p1,p2;
struct {int a,b;} p3;
struct point p4;
p1.x = 10; p1.y = 10;
p2=p1; // ok
p3=p1; // ERROR
p4=p1; // ok
}
CSC3403 Comparative Programming Languages Variables  Identifiers 32
Type compatibility ....
• structure type compatibility
– the type of both variables have same structure
 less restrictive than name compatibility
# somewhat more complex to implement
• in general, type compability applies to expressions, not just variables
• more examples: Sebesta §5.7
CSC3403 Comparative Programming Languages Variables  Identifiers 33
Named constants
• e.g. const int x = 10; // C++
• a variable which is initialised and cannot be assigned to
• value  address bound at same time
• optimisers may keep in register
 advantage: readability, easy to modify code when it does not contain
“magic numbers”
• do not confuse with named literal
#define TABLESIZE 128
CSC3403 Comparative Programming Languages Variables  Identifiers 34
Initialisation
• variable can be initialised by declaration statement
• initialisation is dependant on kind of variable:
– static variable: value is stored in executable file
– dynamic variable: implicit assignment statement executed at run time
It is a shorthand rather than extra feature.
The following two C fragments are semantically identical:
void f () { void f () {
int i = 42; int i;
i = 42;
... ...
} }
• some languages guarantee to automatically initialise (e.g. integers to 0)
CSC3403 Comparative Programming Languages Variables  Identifiers 35
A few conclusions
• these features are considered “good”
 static typing
 strong typing
 static scoping
 automatic dynamic memory management (garbage collection)
• these features are considered “poor”(or use with caution!)
# aliasing
# implicit variable declaration
# unrestricted use of dynamic binding
# dynamic scoping
# dynamic type of variables
 if used with care (C++ dynamic function binding)
CSC3403 Comparative Programming Languages Variables  Identifiers 36

Weitere ähnliche Inhalte

Was ist angesagt?

DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScriptRasan Samarasinghe
 
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingC++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingFrancesco Casalegno
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaMichael Stal
 
Xbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for JavaXbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for Javameysholdt
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric SystemErin Dees
 
Java basics variables
 Java basics   variables Java basics   variables
Java basics variablesJoeReddieMedia
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at WorkErin Dees
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalMichael Stal
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's RevengeErin Dees
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreErin Dees
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Gamindu Udayanga
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stalMichael Stal
 

Was ist angesagt? (20)

Cpprm
CpprmCpprm
Cpprm
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Java q ref 2018
Java q ref 2018Java q ref 2018
Java q ref 2018
 
C++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect ForwardingC++11: Rvalue References, Move Semantics, Perfect Forwarding
C++11: Rvalue References, Move Semantics, Perfect Forwarding
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
 
Gdb cheat sheet
Gdb cheat sheetGdb cheat sheet
Gdb cheat sheet
 
Xbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for JavaXbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for Java
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
 
Java basics variables
 Java basics   variables Java basics   variables
Java basics variables
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
Thnad's Revenge
Thnad's RevengeThnad's Revenge
Thnad's Revenge
 
JRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists AnymoreJRuby, Not Just For Hard-Headed Pragmatists Anymore
JRuby, Not Just For Hard-Headed Pragmatists Anymore
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++Pointers Refrences & dynamic memory allocation in C++
Pointers Refrences & dynamic memory allocation in C++
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stal
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Core java
Core javaCore java
Core java
 

Andere mochten auch

Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8Kousuke Ruichi
 
Algorithms Vs Meta Language
Algorithms Vs Meta LanguageAlgorithms Vs Meta Language
Algorithms Vs Meta LanguageKelly Bauer
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprogramsbaran19901990
 
How to build a news website use CMS wordpress
How to build a news website use CMS wordpressHow to build a news website use CMS wordpress
How to build a news website use CMS wordpressbaran19901990
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentationbaran19901990
 
Nhập môn công tác kỹ sư
Nhập môn công tác kỹ sưNhập môn công tác kỹ sư
Nhập môn công tác kỹ sưbaran19901990
 
Config websocket on apache
Config websocket on apacheConfig websocket on apache
Config websocket on apachebaran19901990
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesTeerawat Issariyakul
 
Memory allocation
Memory allocationMemory allocation
Memory allocationsanya6900
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsSaeed Iqbal
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and DynamicSneh Pahilwani
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clSaumya Sahu
 

Andere mochten auch (20)

Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8
 
Subprogram
SubprogramSubprogram
Subprogram
 
Algorithms Vs Meta Language
Algorithms Vs Meta LanguageAlgorithms Vs Meta Language
Algorithms Vs Meta Language
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprograms
 
Hadoop
HadoopHadoop
Hadoop
 
How to build a news website use CMS wordpress
How to build a news website use CMS wordpressHow to build a news website use CMS wordpress
How to build a news website use CMS wordpress
 
Introduction to HBase
Introduction to HBaseIntroduction to HBase
Introduction to HBase
 
08 subprograms
08 subprograms08 subprograms
08 subprograms
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Datatype
DatatypeDatatype
Datatype
 
Chapter2
Chapter2Chapter2
Chapter2
 
Nhập môn công tác kỹ sư
Nhập môn công tác kỹ sưNhập môn công tác kỹ sư
Nhập môn công tác kỹ sư
 
Config websocket on apache
Config websocket on apacheConfig websocket on apache
Config websocket on apache
 
Control structure
Control structureControl structure
Control structure
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variables
 
Memory allocation
Memory allocationMemory allocation
Memory allocation
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutions
 
Chapter 17 dccn
Chapter 17 dccnChapter 17 dccn
Chapter 17 dccn
 
Scope - Static and Dynamic
Scope - Static and DynamicScope - Static and Dynamic
Scope - Static and Dynamic
 
Computer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 clComputer Fundamentals Chapter 12 cl
Computer Fundamentals Chapter 12 cl
 

Ähnlich wie Topics on Imperative Languages Variables

220 runtime environments
220 runtime environments220 runtime environments
220 runtime environmentsJ'tong Atong
 
Java platform
Java platformJava platform
Java platformVisithan
 
Ch 2 Names scopes and bindings.pptx
Ch 2 Names scopes and bindings.pptxCh 2 Names scopes and bindings.pptx
Ch 2 Names scopes and bindings.pptxRanjanaShevkar
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_iNico Ludwig
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxSaqlainYaqub1
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH SOLUTIONS
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011Patrick Walton
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
Introduction to c
Introduction to cIntroduction to c
Introduction to cAjeet Kumar
 
2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdfcifoxo
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_iNico Ludwig
 

Ähnlich wie Topics on Imperative Languages Variables (20)

220 runtime environments
220 runtime environments220 runtime environments
220 runtime environments
 
Java platform
Java platformJava platform
Java platform
 
chapter 5.ppt
chapter 5.pptchapter 5.ppt
chapter 5.ppt
 
Ch 2 Names scopes and bindings.pptx
Ch 2 Names scopes and bindings.pptxCh 2 Names scopes and bindings.pptx
Ch 2 Names scopes and bindings.pptx
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i
 
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
cs8251 unit 1 ppt
cs8251 unit 1 pptcs8251 unit 1 ppt
cs8251 unit 1 ppt
 
Modern C++
Modern C++Modern C++
Modern C++
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.ppt
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 

Mehr von suthi

Object Oriented Programming -- Dr Robert Harle
Object Oriented Programming -- Dr Robert HarleObject Oriented Programming -- Dr Robert Harle
Object Oriented Programming -- Dr Robert Harlesuthi
 
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGS
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGSTHE ROLE OF EDGE COMPUTING IN INTERNET OF THINGS
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGSsuthi
 
EDGE COMPUTING: VISION AND CHALLENGES
EDGE COMPUTING: VISION AND CHALLENGESEDGE COMPUTING: VISION AND CHALLENGES
EDGE COMPUTING: VISION AND CHALLENGESsuthi
 
Document Classification Using KNN with Fuzzy Bags of Word Representation
Document Classification Using KNN with Fuzzy Bags of Word RepresentationDocument Classification Using KNN with Fuzzy Bags of Word Representation
Document Classification Using KNN with Fuzzy Bags of Word Representationsuthi
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESsuthi
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESsuthi
 
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTES
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTESPARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTES
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTESsuthi
 
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTESSOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTESsuthi
 
COMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTESCOMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTESsuthi
 
DATA BASE MANAGEMENT SYSTEM - SHORT NOTES
DATA BASE MANAGEMENT SYSTEM - SHORT NOTESDATA BASE MANAGEMENT SYSTEM - SHORT NOTES
DATA BASE MANAGEMENT SYSTEM - SHORT NOTESsuthi
 
OPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESOPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESsuthi
 
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTES
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTESSOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTES
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTESsuthi
 
ALGORITHMS - SHORT NOTES
ALGORITHMS - SHORT NOTESALGORITHMS - SHORT NOTES
ALGORITHMS - SHORT NOTESsuthi
 
COMPUTER NETWORKS - SHORT NOTES
COMPUTER NETWORKS - SHORT NOTESCOMPUTER NETWORKS - SHORT NOTES
COMPUTER NETWORKS - SHORT NOTESsuthi
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESsuthi
 
ARTIFICIAL INTELLIGENCE - SHORT NOTES
ARTIFICIAL INTELLIGENCE - SHORT NOTESARTIFICIAL INTELLIGENCE - SHORT NOTES
ARTIFICIAL INTELLIGENCE - SHORT NOTESsuthi
 
LIGHT PEAK
LIGHT PEAKLIGHT PEAK
LIGHT PEAKsuthi
 
Action Recognition using Nonnegative Action
Action Recognition using Nonnegative ActionAction Recognition using Nonnegative Action
Action Recognition using Nonnegative Actionsuthi
 
C Programming Tutorial
C Programming TutorialC Programming Tutorial
C Programming Tutorialsuthi
 
Data structure - mcqs
Data structure - mcqsData structure - mcqs
Data structure - mcqssuthi
 

Mehr von suthi (20)

Object Oriented Programming -- Dr Robert Harle
Object Oriented Programming -- Dr Robert HarleObject Oriented Programming -- Dr Robert Harle
Object Oriented Programming -- Dr Robert Harle
 
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGS
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGSTHE ROLE OF EDGE COMPUTING IN INTERNET OF THINGS
THE ROLE OF EDGE COMPUTING IN INTERNET OF THINGS
 
EDGE COMPUTING: VISION AND CHALLENGES
EDGE COMPUTING: VISION AND CHALLENGESEDGE COMPUTING: VISION AND CHALLENGES
EDGE COMPUTING: VISION AND CHALLENGES
 
Document Classification Using KNN with Fuzzy Bags of Word Representation
Document Classification Using KNN with Fuzzy Bags of Word RepresentationDocument Classification Using KNN with Fuzzy Bags of Word Representation
Document Classification Using KNN with Fuzzy Bags of Word Representation
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
 
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTES
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTESPARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTES
PARALLEL ARCHITECTURE AND COMPUTING - SHORT NOTES
 
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTESSOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
SOFTWARE QUALITY ASSURANCE AND TESTING - SHORT NOTES
 
COMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTESCOMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTES
 
DATA BASE MANAGEMENT SYSTEM - SHORT NOTES
DATA BASE MANAGEMENT SYSTEM - SHORT NOTESDATA BASE MANAGEMENT SYSTEM - SHORT NOTES
DATA BASE MANAGEMENT SYSTEM - SHORT NOTES
 
OPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTESOPERATING SYSTEM - SHORT NOTES
OPERATING SYSTEM - SHORT NOTES
 
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTES
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTESSOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTES
SOFTWARE ENGINEERING & ARCHITECTURE - SHORT NOTES
 
ALGORITHMS - SHORT NOTES
ALGORITHMS - SHORT NOTESALGORITHMS - SHORT NOTES
ALGORITHMS - SHORT NOTES
 
COMPUTER NETWORKS - SHORT NOTES
COMPUTER NETWORKS - SHORT NOTESCOMPUTER NETWORKS - SHORT NOTES
COMPUTER NETWORKS - SHORT NOTES
 
DATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTESDATA STRUCTURES - SHORT NOTES
DATA STRUCTURES - SHORT NOTES
 
ARTIFICIAL INTELLIGENCE - SHORT NOTES
ARTIFICIAL INTELLIGENCE - SHORT NOTESARTIFICIAL INTELLIGENCE - SHORT NOTES
ARTIFICIAL INTELLIGENCE - SHORT NOTES
 
LIGHT PEAK
LIGHT PEAKLIGHT PEAK
LIGHT PEAK
 
Action Recognition using Nonnegative Action
Action Recognition using Nonnegative ActionAction Recognition using Nonnegative Action
Action Recognition using Nonnegative Action
 
C Programming Tutorial
C Programming TutorialC Programming Tutorial
C Programming Tutorial
 
Data structure - mcqs
Data structure - mcqsData structure - mcqs
Data structure - mcqs
 

Kürzlich hochgeladen

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 

Kürzlich hochgeladen (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 

Topics on Imperative Languages Variables

  • 1. Topics on Imperative Languages Variables: names, bindings, type, scope Sebesta Chapter 5 Data Types Sebesta Chapter 6 Expressions Sebesta Chapter 7 Control Statements Sebesta Chapter 8 Subprograms: Concepts & Implementation Sebesta Chapters 9 & 10 Abstract Data Types Sebesta Chapter 11 Exception Handling Sebesta Chapter 14 Object Oriented languages Sebesta Chapter 12 CSC3403 Comparative Programming Languages Variables & Identifiers 1 Variable concepts • Imperative languages map simply to von Neuman architecture (linear memory, CPU, sequential execution) • Variables correspond to memory cell(s) – integers, floats (direct support for operations) – record or structure – (variables may be optimised to registers) • Variable attributes Œ name  value  type  lifetime Ž location ‘ scope • related issues: named constants, initialisation CSC3403 Comparative Programming Languages Variables & Identifiers 2 Names • synonym: identifiers parent(amy,cathy). parent(bill,cathy). • applies also to names of functions, constants, types, etc. • issues – Maximum length ∗ limited: truncate or error if identifer too long ∗ unlimited: storage/implementation considerations (This is really an implementation issue.) – valid chars—typically: 0-9 a-z A-Z _~; first char non-numeric – case sensitive? – special words ∗ keywords — depend on context ⇒ dangerous (see next...) ∗ reserved words—e.g. if then return ∗ predefined names (system/library definitions—may be redefined) writeln printf cout map fold CSC3403 Comparative Programming Languages Variables & Identifiers 3 Example: Keywords considered dangerous 1962: NASA Mariner 1 Venus probe lost • Early FORTRAN compilers implemented keywords • Early FORTRAN compilers ignored spaces • Programmer meant to write: DO 5 I = 1, 3 ...body of loop... 5 CONTINUE • Problem: period instead of comma DO 5 I = 1. 3 which is interpreted as the assignment: DO5I = 1.3 • Result: loop not executed ⇒ program fails ⇒ Mariner 1 lost CSC3403 Comparative Programming Languages Variables & Identifiers 4
  • 2. Name space • identifiers can be partitioned into classes: e.g. variables, types, record names, field names, enumerated constants, module names, etc... • where ambiguity cannot occur, only require identifiers to be unique within their name space • a name space is defined by the class(es) of identifier(s) it contains • E.g. allow field names and variable names to occupy separate name spaces, but variables and constants should occupy the same name space. struct s { int a; int s;}; int main(){ struct s s; s.s = 1; } • Note: Modern OO languages also implement explicit programmer specified namespaces; this is different from the language-defined namespaces discussed here. CSC3403 Comparative Programming Languages Variables & Identifiers 5 Variable location • Each variable instance has a unique start address • It will typically occupy a range of addresses (Very few data types can be held in just 1 byte.) • A variable instance is defined by its 1. name 2. declaration site — which subprogram/block 3. current block instance (only required if recursive call) CSC3403 Comparative Programming Languages Variables & Identifiers 6 Example of variable instances There are 3 declarations of var in this program, but as many as 9 instances! #include <stdio.h> int var; /* 1: global variable */ int f1(){ int var; /* 2: local variable */ var = 42; } int f2(int var){ /* 3: parameter == local var */ if (var==0) return 1; else return var * f2(var-1); } main(){ f1(); var = f2(6); printf("%dn", var); } CSC3403 Comparative Programming Languages Variables & Identifiers 7 Variables Aliases alias: 1 location but >1 name or access method • explicit: Fortran EQUIVALENCE, C union struct symtabEntry{ char *name; int type; union { int ival; float fval; char *sval; } value; } Memory layout: 0 4 8 12 ival name type fval sval CSC3403 Comparative Programming Languages Variables & Identifiers 8
  • 3. Variables Aliases .... • indirect: via pointers int x,*p,*q; p=&x; q=&x; *p=42; printf("meaning of life = %dn", *q); • indirect: call-by-reference parameters void f(int *a, int *b) { *a++; *b++; } ... f(&x, &x); ... Comments • Aliasing is a bad idea; reduces program readability (but variant records can be useful in rare system programming applications) • Better dynamic memory systems and abundant computer memory has reduced/removed the need for aliasing CSC3403 Comparative Programming Languages Variables & Identifiers 9 Variable type A variable’s type defines (for language-specified types): • the range of values that the variable can store (implementation dependent) • the physical storage requirements (implementation dependent) • the set of legal operations on the variable (language defined) Variable value • each variable instance has a value • may be automatically initialised (see later) • a value is contained in set of contiguous locations — called a cell • r-value is value (contents of cell) • l-value is address (location of cell) CSC3403 Comparative Programming Languages Variables & Identifiers 10 Lifetime & Storage • when is a memory cell allocated? allocation ≡ location binding • when is a memory cell deallocated? • lifetime is time from allocation to deallocation (binding to unbinding) • 4 classes of variable – static variables – stack-dynamic variables (automatic) – explicit dynamic variables – implicit dynamic variables CSC3403 Comparative Programming Languages Variables & Identifiers 11 Static variables • allocated before run time (usually link or load time) • executable file contains space for static variables. • the binding exists for entire lifetime of the program easy cheap to access — compiler can compute the address at compile time handy for global variables which are used throughout program useful for subprogram local variables (e.g. C static) when history is required but variable is only needed in subprogram # static parameters preclude recursion CSC3403 Comparative Programming Languages Variables Identifiers 12
  • 4. Stack-dynamic variables • allocated when code containing declaration is executed • elaboration or instantiation is the name of the binding process • variables are stored on the run-time stack (RTS) • each block or subprogram invocation allocates a chunk of storage (activation record instance) on the RTS • subprogram exit ⇒ storage deallocation # disadvantage: slower access — address must be calculated at run time advantages: – enables recursion – lower average memory usage – smaller executables – smaller libraries CSC3403 Comparative Programming Languages Variables Identifiers 13 Explicit dynamic variables • explicitly created by programmer code • not bound to variable — pointer variable holds address struct stentry *stnode; // C++ stnode = new struct stentry; // allocate ... delete stnode; // deallocate • memory is allocated from the heap • there is often a maximum heap size ideal for dynamic structures whose size is unknown at compile time (trees, lists, etc.) # opportunity for programmer errors (pointers—see later) # cost of reference (indirect via pointer: 2 memory accesses) # cost allocation/deallocation (heap magement). CSC3403 Comparative Programming Languages Variables Identifiers 14 Implicit dynamic variables • employed by dynamic languages like APL, scripting languages • storage allocated at assignment time advantage: flexible # disadvantage: costly, poorer error detection CSC3403 Comparative Programming Languages Variables Identifiers 15 Scope • variable scope: from where can it be referenced? (where is it visible?) • scope rules define how to resolve references to non-local variables (there may be 1 non-local variables of same name) • a local variable is declared in current program unit • each program unit introduces a new “scope” – subprogram (a.k.a. procedure, function) a named subprogram, usually with parameters – block anonymous program unit in C/C++: { .... } – module named collection of definitions. (C++: namespace) • two kinds – static: compiler can resolve scope – dynamic: scope resolved at run time CSC3403 Comparative Programming Languages Variables Identifiers 16
  • 5. Static scoping rules • to resolve reference to a variable 1. locate the variable’s declaration 2. retrieve variable’s attributes (type, address, etc) • search algorithm unit ⇐ referencing unit; found ⇐ False; done ⇐ False; repeat if variable declared in unit then use this variable declaration found ⇐ True; done ⇐ True else if unit is not outermost then unit ⇐ staticParent(unit) else done ⇐ True until done CSC3403 Comparative Programming Languages Variables Identifiers 17 Static scoping rules .... Equivalent recursive definition: A variable (say x) is visible within a referencing unit if it is either • declared within that unit, or • is visible from the static parent of the unit. The referencing environment of a unit is the union of • all identifiers declared local to the unit, and • identifiers in the static parent’s referencing environment with names different to those declared in this unit. CSC3403 Comparative Programming Languages Variables Identifiers 18 Nested scope Program a b c d e procedure main; var a; procedure sub1; var b; procedure sub2; var c; begin end; procedure sub3; var d; begin end; begin end; procedure sub4; var e; begin end; begin end; CSC3403 Comparative Programming Languages Variables Identifiers 19 Hidden variables Program xmain x1 x2 x3 x4 procedure main; var x; procedure sub1; var x; procedure sub2; var x; begin end; procedure sub3; var x; begin end; begin end; procedure sub4; var x; begin end; begin end; CSC3403 Comparative Programming Languages Variables Identifiers 20
  • 6. Static scoping issues • Aim: to restrict access to vars/procs only to those units that need them, thus avoiding the chance of accidental programming errors caused by improper access. • Non-nested function declarations (as in C) allow unrestricted calling of functions. (With some exceptions—see later.) • Nested declarations allow procedure calls only to Child procedure (but not granchild etc) # Any ancestor procedure • problems (see discussion Sebesta §5.8.3 ) – access not rescrictive enough (ancestors) – overuse of global variables to provide resource sharing – key question: How can two subprograms share local variables such that no other subprograms can see them? modules, classes, namespaces (see later) CSC3403 Comparative Programming Languages Variables Identifiers 21 Case study: Scope in C File Program x1 x2 x3 x4 f1,f3,f4 f2 p1.c int x; /* x1 */ main(){ int x; /* x2 */ x=2; } int f1(){ x=1; } p2.c static int x; /* x3 */ static int f2(){ x=3; } p3.c int f3(){ static int x; /* x4 */ x=4; } extern int x; /* x1 */ int f4(){ x=1; } CSC3403 Comparative Programming Languages Variables Identifiers 22 Dynamic scope • Apl, Snobol, early Lisp • scope resolved at run time • search dynamic parent chain dynamic parent ≡ calling procedure callee automatic inherits caller’s locals # cost of dynamic scope resolution # difficulty of programming / debugging Consider proc p() {a := a + 1; } Q: Which instance of variable “a” is being updated? A: Cannot tell from static structure of program! You must trace through program execution to find out. CSC3403 Comparative Programming Languages Variables Identifiers 23 Binding concepts • a binding is an association – variable attribute ←→ value of attribute – operation ←→ symbol – executable code ←→ physical location – conceptual/abstract ←→ concrete/value • binding times (from early to late) – language design (operator symbols) – language implementation (range of data types) – compile time (var ←→ type) – link time (address of vars, functions in executable image file) – load time (physical variable addresses) – run time (dynamic variable addresses, DLL function addresses) CSC3403 Comparative Programming Languages Variables Identifiers 24
  • 7. Static and Dynamic Binding • static binding: bound before run time • dynamic binding: bound during run time • consider variable attributes – name is always statically determined – value is always dynamically bound (else it is a constant!) – location and lifetime can safely be either static or dynamic – type and scope can be either static or dynamic. Static binding is safer and more readable for these attributes. CSC3403 Comparative Programming Languages Variables Identifiers 25 Type bindings — motivation Q: Why do we need types? A: At reference time, a variable must have a type so that either 1. on “read” (e.g. variable access), cell contents can be interpreted correctly 2. on “write” (e.g. assignment to variable), correct conversions are made E.g. consider int a,b; float c; ... c = a + b; Key design questions • how is the type determined? – explicit vs. implicit declarations • when does variable–type binding occur? – static vs. dynamic CSC3403 Comparative Programming Languages Variables Identifiers 26 How is (static) type specified/determined? • explicit declarations – mandatory (C++, Pascal, most modern languages) – optional ([uncommon] KR C functions default to int) • implicit declarations – Fortran, Basic, PL/1 – Fortran: first letter convention: I J K L M N – others: first use convention – disadvantage: typographical errors undetected coutner = counter + 1 • inference (implicit declaration supported by optional explicit declarations) – ML, Miranda, Haskell, Gofer – all types can be statically inferred – comparison of declared vs inferred types finds errors CSC3403 Comparative Programming Languages Variables Identifiers 27 Dynamic type binding • APL, shell languages (e.g. Perl, Tcl) • automatic conversions required advantage: flexibility, generic subprograms possible, e.g.: int inc(a) {return a+1;} // a can be any numeric type # disadvantages – typographical errors not caught (see previous example) – cost of dynamic type inference – interpreted implementions usually required • Note: advanced languages (Ada, C++, Haskell) provide polymorphic type-checked subprograms – provides generic subprograms with static type checking CSC3403 Comparative Programming Languages Variables Identifiers 28
  • 8. Typing concepts • Type error A type error occurs when an operator (or function) is applied to an operand (e.g. a variable, but in genaral any expression) whose type is not compatible with the operator’s parameter type. If this error is not detected by the language implementation system ⇒ program bug! int i=1; double f,*p; p = (double *) i; *p = f; • Type checking To check that an operator or subprogram is applied to arguments of the correct type. (Assignment is considered a binary operator). • Compatible type Either a type which matches the operator’s definition or a type which can be automatically converted, using language rules, into the correct matching type. • Coersion Automatic conversion of types. CSC3403 Comparative Programming Languages Variables Identifiers 29 Strong typing Definition: All type errors in a program can be detected • no imperative language is strongly typed • typical problems: variant records, non-checked type casts • many languages (e.g. Java, C#, Ada) are almost strongly typed • modern functional languages are strongly typed (static typing) • coercion weakens strong typing Comment Strong typing is seen by most language researchers/designers as a “good idea”, and most newer languages have very good type checking. CSC3403 Comparative Programming Languages Variables Identifiers 30 Type conversion examples Consider “assignment” of a floating point to an integer. C: coersion, type error int i,j; double a=999999999.5, b=9999999999.5; int main(){ i = a; j = b; printf(i=%d j=%dn,i,j);} execution ⇒ i=999999999 j=-2147483648 Haskell: strong typing: explicit conversion + runtime check Hugs :t truncate truncate :: (RealFrac a, Integral b) = a - b Hugs (truncate 999999999.5)::Int 999999999 Hugs (truncate 9999999999.5)::Int Program error: arithmetic overflow CSC3403 Comparative Programming Languages Variables Identifiers 31 Type compatibility • name type compatibility – both varables appear in same declaration or both variables declared with the same type name – C++ uses name compatibility main(){ //C++ struct point {int x,y;} p1,p2; struct {int a,b;} p3; struct point p4; p1.x = 10; p1.y = 10; p2=p1; // ok p3=p1; // ERROR p4=p1; // ok } CSC3403 Comparative Programming Languages Variables Identifiers 32
  • 9. Type compatibility .... • structure type compatibility – the type of both variables have same structure less restrictive than name compatibility # somewhat more complex to implement • in general, type compability applies to expressions, not just variables • more examples: Sebesta §5.7 CSC3403 Comparative Programming Languages Variables Identifiers 33 Named constants • e.g. const int x = 10; // C++ • a variable which is initialised and cannot be assigned to • value address bound at same time • optimisers may keep in register advantage: readability, easy to modify code when it does not contain “magic numbers” • do not confuse with named literal #define TABLESIZE 128 CSC3403 Comparative Programming Languages Variables Identifiers 34 Initialisation • variable can be initialised by declaration statement • initialisation is dependant on kind of variable: – static variable: value is stored in executable file – dynamic variable: implicit assignment statement executed at run time It is a shorthand rather than extra feature. The following two C fragments are semantically identical: void f () { void f () { int i = 42; int i; i = 42; ... ... } } • some languages guarantee to automatically initialise (e.g. integers to 0) CSC3403 Comparative Programming Languages Variables Identifiers 35 A few conclusions • these features are considered “good” static typing strong typing static scoping automatic dynamic memory management (garbage collection) • these features are considered “poor”(or use with caution!) # aliasing # implicit variable declaration # unrestricted use of dynamic binding # dynamic scoping # dynamic type of variables if used with care (C++ dynamic function binding) CSC3403 Comparative Programming Languages Variables Identifiers 36