Scope is an enclosing context where values and expressions are associated. Use this tag for questions about different types of scope as well for questions where scope may be unclear.
Questions tagged [scope]
17524 questions
58
votes
10 answers
How to live with Emacs Lisp dynamic scoping?
I've learned Clojure previously and really like the language. I also love Emacs and have hacked some simple stuff with Emacs Lisp. There is one thing which prevents me mentally from doing anything more substantial with Elisp though. It's the concept…

auramo
- 13,167
- 13
- 66
- 88
58
votes
1 answer
Is it a good practice to call functions in a package via ::
I'm writing some R functions that employ some useful functions in other packages like stringr and base64enc. Is it good not to call library(...) or require(...) to load these packages first but to use :: to directly refer to the function I need,…

Kun Ren
- 4,715
- 3
- 35
- 50
58
votes
7 answers
JavaScript Callback Scope
I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object in a callback function.
function foo(id) {
this.dom = document.getElementById(id);
this.bar = 5;
var self = this;
…

Chris MacDonald
- 5,975
- 4
- 34
- 35
56
votes
2 answers
How to get all variables defined in the current scope/symbol table?
Is there a function and/or object and/or extension in PHP that will let you view all the variables defined in the current scope? Something like:
var_export($GLOBALS)
but only showing variables in the current symbol table.

Alana Storm
- 164,128
- 91
- 395
- 599
56
votes
3 answers
How references to variables are resolved in Python
This message is a a bit long with many examples, but I hope it
will help me and others to better grasp the full story of variables
and attribute lookup in Python 2.7.
I am using the terms of PEP 227
(http://www.python.org/dev/peps/pep-0227/) for…

user3022222
- 857
- 9
- 9
56
votes
4 answers
Function declarations inside if/else statements?
How are function declarations handled?
var abc = '';
if (1 === 0) {
function a() {
abc = 7;
}
} else if ('a' === 'a') {
function a() {
abc = 19;
}
} else if ('foo' === 'bar') {
function a() {
abc = 'foo';
…

HellaMad
- 5,294
- 6
- 31
- 53
55
votes
2 answers
I can pass a variable from a JSP scriptlet to JSTL but not from JSTL to a JSP scriptlet without an error
The following code causes an error:
<%
String resp = "abc";
resp = resp + test;
pageContext.setAttribute("resp", resp);
%>
The error says
"error a line 4: unknown symbol…

Cornish
- 899
- 2
- 9
- 8
55
votes
6 answers
How can I return a variable from a $.getJSON function
I want to return StudentId to use elsewhere outside of the scope of the $.getJSON()
j.getJSON(url, data, function(result)
{
var studentId = result.Something;
});
//use studentId here
I would imagine this has to do with scoping, but it doesn't…

Sean Chambers
- 8,572
- 7
- 41
- 55
55
votes
7 answers
Multiple directives [myPopup, myDraggable] asking for new/isolated scope
I wrote a directive for dialogs (myPopup) and another one for dragging this dialog (myDraggable), but I allways get the error:
Multiple directives [myPopup, myDraggable] asking for new/isolated scope
Here is a Plunker:…

Martin
- 1,283
- 2
- 14
- 28
55
votes
12 answers
Calling a Function defined inside another function in Javascript
I am calling a function on button click like this:
function outer() {
alert("hi");
}
It works fine and I get an alert:
Now when I do like this:
function outer() {
function…

Mike
- 3,348
- 11
- 45
- 80
54
votes
4 answers
When to use Spring prototype scope?
I want to know when should I exactly use the prototype scope in Spring? I have understood that singleton returns the same object instance if the bean is requested for.
Then why should we consider prototype?
Explanations with examples would help a…

Rahul
- 619
- 1
- 5
- 15
54
votes
6 answers
clearInterval() not working
Possible Duplicate:
JS - How to clear interval after using setInterval()
I have a function that changes the font-family of some text every 500 ms using setInterval (I made it just to practice JavaScript.) The function is called by clicking on an…

Matt Sanchez
- 583
- 1
- 6
- 10
53
votes
6 answers
C++ - value of uninitialized vector
I understand from the answer to this question that values of global/static uninitialized int will be 0. The answer to this one says that for vectors, the default constructor for the object type will be called.
I am unable to figure out - what…

anon
- 583
- 1
- 4
- 5
53
votes
2 answers
How do I get current scope dom-element in AngularJS controller?
I have a list of outerItems. Inside each outerItem, I have a list of innerItems. They are dynamically sorted.
When mouse cursor points at one of innerItems, I have to show the popup window right above that innerItem element.
Popup div is body's…

gorpacrate
- 5,109
- 3
- 21
- 18
52
votes
3 answers
Why do multiple-inherited functions with same name but different signatures not get treated as overloaded functions?
The following snippet produces an "ambigious call to foo" error during compilation, and I'd like to know if there is any way around this problem without fully qualifying the call to foo:
#include
struct Base1{
void foo(int){
…

Xeo
- 129,499
- 52
- 291
- 397