0

From my recitation class -

In free variables (in function activation):

  • Static scoping: free variables are evaluated in the context of the defining occurrence of the function . include many you know: ML, Java, C++.

  • Dynamic scoping: free variables in the function body are evaluated in the context of the function call

  • Static languages: Common Include many you know: ML, Java, C++ Advantages modularity easier variable access by the compiler

Can you give an example which describes why does C++ regards as Static languages ?

Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
URL87
  • 10,667
  • 35
  • 107
  • 174
  • 1
    If you mean static-typed languages by static languages: Well, maybe because the ___types are determined at compile time___, e.g. `int an_integer; char a_character;`. For comparison: `var am_i_an_int = {}; am_i_an_int = "string"; am_i_an_int = 1;` is first an `object`, then a string, and then a number in JavaScript. – Zeta Feb 25 '13 at 11:59
  • i guess you want to know why C++ is static "typed" language, if so it got nothing to do with scoping, i guess http://stackoverflow.com/questions/125367/dynamic-type-languages-versus-static-type-languages and http://stackoverflow.com/questions/583507/moving-from-static-language-to-dynamic might help you... to have basic idea... – Saqlain Feb 25 '13 at 11:59

2 Answers2

2

static language mean “statically typed language” . for example type of a variable can't be change and defined statically at compilation time.
But not because of any of reason you mentioned

int i = 10;

i in int can be char.

in opposite Python for example:

>>> x = "yourname"      # x is pointing string 
>>> x = 5               # x pointing number

So Python is an example of “dynamic typed language”

Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
0

A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time. In C++, variables need to be defined before they are used so that compilers know what type they are, and hence is statically typed.

Please take a look at below articles

http://www.jvoegele.com/software/langcomp.html
http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/
http://en.wikipedia.org/wiki/Type_system
http://en.wikipedia.org/wiki/C%2B%2B

Nidhish Krishnan
  • 20,593
  • 6
  • 63
  • 76