Any languages whose functions cannot access global scope? -


I am writing something in a quote of basic that does a user-defined function which can only reach local variables; For example, the following code:

  let's S $ = "hello, world!" Fn.def Some functions ($) print s $ fn.rtn "a string" fn.end X $ = someFunction $ ()   

will print a blank line, because S There is no value in the context of $ of some function $ .

Question: Are there common uses in other languages ​​which are global scope that can not be accessed from within a function?

The basis of this question is the misunderstanding, that this speech of basic, like most others, is not a global area There are many languages ​​in the same category.

An earlier explanation. There was one area in many early computer languages, in which all the variables were defined. When it became very limited, they added a suburban capacity that either shared a common radius (cobol display and original gossab) or the logic is passing (Fortran call and return) with a completely different region defined Does.

One language was different: Algol defined the nested lexical scope, so that in the context of a variable the block is inside or outside the nested block. It was an unusual feature and was not widely copied.

Fortran also provides a linking system named Command. It was adopted by some other languages. C block scope, external area (with external relation), but nested functions have not been added, so the function can never access the variable from any other function's scope.

Speaking of the origin you belong to the original / fortran family. It has non-overlapping scope for each main program and user-defined functions, but apparently there is no external linkage. Regardless of how written they are, user-defined functions have their own scope and of course they can not access the variables in the main program, which is in a very different area. Some bids of Basic have a similar-like feature, but I do not think it does this.

So the answer is that most languages ​​(of this type) do not provide nosted scoops and internal scope for using the contents of an external one [Lisp family tree is completely different.]

An interesting exception is. Object-oriented languages ​​are mostly derived from Simula, which was a language like Pascal and used to present the idea of ​​nesting in a way that came within the scope of the class. This idea has certainly been caught.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -