Questions tagged [scope]

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.

17524 questions
5
votes
5 answers

Scope of char * compared with char array in C

These two forms of the same variable, when defined within scope of a function block should, I would think, have identical scope, i.e. within the function blocks {...} where they are defined: char str1[] = "int_1 < int_2"; char *str1 = "int_1 <…
ryyker
  • 22,849
  • 3
  • 43
  • 87
5
votes
1 answer

Question about importing js module and function scope(local/global)

Hi I'm new in js and I'm trying to understand local/global scope when importing js module. Below is my html/js file which is working. Below is my html/js file which is not working. Please tell me the reason why I have to put…
5
votes
2 answers

What is the scope of the template reference variable in Angular?

What is the scope of the template reference variable in Angular? I can not find a clear answer to my question in documentation. Even though empirically I can say that the whole template can access the template reference variable. 1 Is it the case?…
Sasuke Uchiha
  • 857
  • 2
  • 11
  • 23
5
votes
1 answer

Reassignment of Dictionary Values inside a Function in Julia

New to Julia and hence, likely a basic question. x = 1 function someFn() print(x) x = 3 end This throws an error at print(x) because global x inside is not seen inside the function. This makes sense. x = [1,2] function someFn() print(x) …
Sundar
  • 53
  • 3
5
votes
2 answers

Why would we use custom scope in spring? When is it needed?

Can any one please help me in understanding custom scope. I went through manual and through many online example and understood how it is being implemented. But, I am still not clear why we need a custom proxy, and why we will go for, limiting the…
Anupam Gupta
  • 1,591
  • 8
  • 36
  • 60
5
votes
3 answers

Immediately self executing function and "this"

I want to create a javascript library, so I thought making it an immediately self executing function would be a nice thing to do to ensure scope safety and everything. But now I'm running into a problem with using the "this" keyword that I don't…
F.P
  • 17,421
  • 34
  • 123
  • 189
5
votes
4 answers

self.scope['user'] in Django channels keeps showing up as AnonymousUser

When I log in to my front end, my self.scope['user'] call in my friends.consumer.py in django channels returns AnonymousUser but when login and call self.scope['user'] in my chat.consumer.py it shows up as the logged in user. For some reason the…
hafkacc
  • 51
  • 1
  • 3
5
votes
5 answers

jQuery variable scope within each

I am trying to build an array containing all the values of every form element. The alert works just find, but on console.log data is empty, am I failing to understand how scoping in javascript works? var data = new Array(); $("#page2…
Pez Cuckow
  • 14,048
  • 16
  • 80
  • 130
5
votes
1 answer

How to use variable from do block assignment line in a where clause?

I have the following sample of code: {-# LANGUAGE ScopedTypeVariables #-} main = do putStrLn "Please input a number a: " a :: Int <- readLn print a putStrLn "Please input a number b: " b :: Int <- readLn print b putStrLn…
altern
  • 5,829
  • 5
  • 44
  • 72
5
votes
3 answers

Structuring Lua classes

I'm constructing a class in Lua that has a number of groups of related functions within it, but am unsure whether there's a better way to structure it. I currently have to develop for a Lua 5.1 environment but am hopeful that Lua 5.3 will be…
ColeValleyGirl
  • 577
  • 15
  • 40
5
votes
2 answers

Python: why can't descriptors be instance variables?

Say I define this descriptor: class MyDescriptor(object): def __get__(self, instance, owner): return self._value def __set__(self, instance, value): self._value = value def __delete__(self, instance): …
Continuation
  • 12,722
  • 20
  • 82
  • 106
5
votes
2 answers

JavaScript scope: referencing parent object member from child member's closure

Newbie to JavaScript here. How do I reference member foo from within member foobar, given that foobar's in a closure? var priv = { foo: "bar", foobar: (function() { return this.foo === "bar"; })() }; The code above fails. In…
5
votes
1 answer

Sentry.io Managing error scopes/contexts on asynchronous Node.js Server

Basically you have concurrent requests in Node.js. And you probably want to enrich possible errors with data specific to each request. This request-specific data can be gathered in different parts of the app via Sentry.configureScope(scope =>…
disfated
  • 10,633
  • 12
  • 39
  • 50
5
votes
2 answers

Is it possible to have hard real-time with lexical scope?

I was reading this paper about the funarg problem, which is really the problem of maintaining the environments of lexical closures. It's an old paper and I'm not sure if the author's conclusions still hold, but he strongly implies that, in order to…
Johnny
  • 51
  • 1
5
votes
3 answers

How to access dynamic local variables

How would I reference a dynamic local variable? This is easily accomplished with a global variable: myPet = "dog"; console.log(window["myPet"]); How would I do the same in a local scope? Specifically what I'm trying to do: myArray =…
Gary
  • 13,303
  • 18
  • 49
  • 71
1 2 3
99
100