#137640 - 2005-04-14 10:18 AM
Re: concept of namespace?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
As far as "file scope" if you 'Dim' a var at the beginning of a script "A" and call that script from script "B". Script "B" will not be able to see those script "A" vars because they are out of scope. Richard, is this type of action what you defined as "file scope"?
Not quite. You have declared a local variable, so it is not visible within functions defined in the same file.
Consider a library where you want constants or variables which are visible to functions and code within the library but not outside the file scope. The constants or variables have to be global to be visible within the function. If they are global then they are also visible outside the file scope, which is not what you want. You will also get a clash with an already defined global of the same name.
Namespaces are pretty close to doing the job, as a "Global" variable restricted to a namespace would effectively be a static variable in the namespace scope.
For the sake of sanity I don't think namespaces should be inherited, as they'd get very nasty very quickly.
|
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 483 anonymous users online.
|
|
|