Questions tagged [global-scope]

Global scope defines a namespace that is fully accessible in the entire program or script.

Global scope defines a namespace that is fully accessible in the entire program or script. Variables, classes and objects that are defined in the global scope can usually be accessed anywhere in the code, and are often referred to as global variables.

108 questions
42
votes
3 answers

ViewState Vs Session ... maintaining object through page lifecycle

Can someone please explain the difference between ViewState and Session? More specifically, I'd like to know the best way to keep an object available (continuously setting members through postbacks) throughout the lifecycle of my page. I currently…
Kyle
  • 10,839
  • 17
  • 53
  • 63
17
votes
5 answers

Difference between File Scope and Global Scope

I am a student and I am confused about global and file scope variables in C and C++. Is there any difference in both perspectives? If yes, please explain in detail.
Iqbal Haider
  • 310
  • 1
  • 3
  • 9
14
votes
3 answers

Is a fully qualified class name down to global scope ever required for out-of-line member function definitions?

This question got me wondering whether it is ever useful/necessary to fully qualify class names (including the global scope operator) in an out-of-class member function definition. On the one hand, I've never seen this done before (and the syntax to…
12
votes
2 answers

How to alias the global namespace in C++11

Short Form: How can I define an alias for the root (global) namespace in C++11 ? It might look like namespace root_namespace = :: ; where the scope resolution operator in its naked form above is a place holder for some handle of the global…
Louis Carole
  • 221
  • 2
  • 5
9
votes
2 answers

Use Laravel touches without global scopes

Concept Problem: I have a very simple problem when using the touches attribute, to automatically update timestamp on a depending model; it correctly does so but also applies the global scopes. Is there any way to turn this functionality off? Or to…
Nicklas Kevin Frank
  • 6,079
  • 4
  • 38
  • 63
9
votes
5 answers

Share a JavaScript library's namespace or use your own?

It is fairly well known in JavaScript that declaring variables within the global scope is a bad thing. So code I tend to work on contains namespaced JavaScript. There seems to be two different approaches taken to this - Adding your application…
Dr. Frankenstein
  • 4,634
  • 7
  • 33
  • 48
6
votes
4 answers

Recommended way to manage global scope data and settings in PHP?

After a few years in PHP development, I saw and heard various ways for storing "global scope data" (globals, constants, ini/XML/YML files, database, singleton properties...). By "global scope data", I mean: Global application/project settings such…
Maxime Pacary
  • 22,336
  • 11
  • 85
  • 113
5
votes
0 answers

Pass variable into global scope and determine if query output is null Laravel

I've translation models and I want to run Global query scope that determine the current locale and return the corresponding value upon it or fall back into English if the translation doesn't exist in DB. I've created a global scope for this purpose…
4
votes
1 answer

Robot Framework Library Dynamic Import Not Remaining Global

Some background I'm using Robot Framework with Python to create a small framework for test automation. I have a few different libraries; a couple are application-specific and one has keywords that I would like to be always available. This…
Sync
  • 107
  • 1
  • 8
4
votes
2 answers

How can I declare an extension with global scope across the solution

I'm trying to write an extension (actually taken from Case insensitive 'Contains(string)') It compensates for the Turkey Test when doing string comparison. The extension itself is simple: public static bool Contains(this string source, string…
rboy
  • 2,018
  • 1
  • 23
  • 35
3
votes
1 answer

What is the cross-platform way to add a JavaScript module to the global scope?

I was having a look at the source code of store.js, in particular how it adds itself to the global scope: if (typeof module != 'undefined') { module.exports = store } else if (typeof define === 'function' && define.amd) { define(store) } else {…
laurent
  • 88,262
  • 77
  • 290
  • 428
3
votes
2 answers

node.js - configure node to load functions into the global scope?

in realier days I saw somewhere that we can configure node-js to execute a loaded module in the global scope, I can't find how to do that now. Why I'm asking? I have some legacy files that define language utilities that I want to use on both the…
Radagast the Brown
  • 3,156
  • 3
  • 27
  • 40
3
votes
3 answers

How do I use Laravel Query Global Scopes

I am implementing Laravel Global Scope as documented here but this seems to be not working for me. Below is my line of code in User.php model
Abhi Burk
  • 2,003
  • 1
  • 14
  • 21
3
votes
2 answers

Angular: How to import a module global that all other modules can access to it. (without re-importing in other modules)

I want to use an UI-Framework globally for all other modules (sub-modules from routing). I'm using the latest versions of Angular and Material (7.2+). https://material.angular.io/ I created an Angular module that imports all Angular Material UI…
Dag
  • 161
  • 1
  • 2
  • 6
3
votes
3 answers

Why won't this variable reference to a non-local scope resolve?

Here's an example to find the greatest common divisor for positive integers a and b, and a <= b. I started from the smaller a and minus one by one to check if it's the divisor of both numbers. def gcdFinder(a, b): testerNum = a def…
chenghuayang
  • 1,424
  • 1
  • 17
  • 35
1
2 3 4 5 6 7 8