Skip to main content

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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
35 views

Scopes and middleware

When registering services, one can optionally wrap these in additional middleware. However, the only way I found to do so in separate and then aggregate was using the .scope function. I particularly ...
João Conde's user avatar
0 votes
0 answers
11 views

Node.js - Making an eventEmitter object be common across different scopes

I am new to node.js and javascript but not coding. This is more of a syntax question of "why does this work?" so I can understand the nuances involved I defined an emitter object in my main....
Jeff Orwick's user avatar
0 votes
0 answers
17 views

Difference in Output Between Two Similar C++ Codes with Nested Loops and transform

I'm experiencing a strange issue with two similar pieces of C++ code that are supposed to perform the same task but yield different results. The problem is around the inner loop statement . While ...
AyushRaj's user avatar
-1 votes
0 answers
74 views

Are namespaces in C++ the same as those in Python? [duplicate]

Namespaces in Python are "a mapping from names to objects". They're a pretty fundamental part of the language, even making it to The Zen of Python. As per cppreference, "namespaces ...
new__'s user avatar
  • 9
1 vote
1 answer
46 views

Absolute prevention of content pollution in output buffer

I have this following code that basically renders partials. However I was trying to find a way to prevent polluting $templatePath variable into the template (the variable is currently accessible from ...
Askalot's user avatar
  • 13
0 votes
0 answers
4 views

How to write a Powershell function that can evaluate "using expressions" both locally without WinRM and remotely through WinRM?

The new IT-issued developer laptops at my org are configured in such a way that fully enabling WinRM is a nightmare - I still can't figure it out. I try to work within lowest-common-denominator ...
Pxtl's user avatar
  • 943
1 vote
1 answer
76 views

C pointers: Function returns a pointer defined in its body [duplicate]

I'm learning C using the book C Programming: A Modern Approach and I have some doubts about the use of pointers and referencing an out-of-scope variables. I've put together three examples to ...
videbar's user avatar
  • 33
-1 votes
1 answer
41 views

Variable used inside function reported not used

This works fine: package main var foo string func main() { fn := func() { foo = "AAA" } fn() } But if we move the variable declaration inside main(): package main ...
Greendrake's user avatar
  • 3,714
1 vote
1 answer
73 views

Unqualified name lookup after using-directives in C++

From cppreference : From the point of view of unqualified name lookup of any name after a using-directive and until the end of the scope in which it appears, every name from namespace-name is visible ...
Rajdeep Sindhu's user avatar
1 vote
2 answers
108 views

Ambiguous variable reference in C++

I have this piece of code #include <iostream> namespace ns{ int a = 10; } using namespace ns; int a = 20; int main(){ std::cout << a; } As per my understanding, when std::cout &...
Rajdeep Sindhu's user avatar
1 vote
0 answers
86 views

How can I overload a constructor in a private nested class without getting a "Resource Not Found" error when I call Inherited Create?

I have a Managed Record named TEmail with a nested private class called TEmailForm that inherits from TForm. The idea is my email Record can create a modal form as needed for the user to type an email....
dallin's user avatar
  • 9,246
0 votes
1 answer
52 views

Variables in Try-Catch blocks with Powershell?

I have been trying to write a script in powershell that renames a file if it does not get transferred correctly through WinSCP. The script looks something like this: # Variables $error = 0 $...
Evan's user avatar
  • 9
0 votes
1 answer
60 views

SwiftUI My Classes dont get injected properly

Im fairly new to SwiftUI and Im trying to build a small game to get used to the syntax but I have the problem that I created a class and created 3 instances in the @main struct but when I try to use ...
KatMood's user avatar
-1 votes
0 answers
47 views

Change function's variable inside another function via argument [duplicate]

I want to find how to change a variable via a function that isn't the one that the variable initiated in using the other function's argument (to make it viable for many usages). Something along these ...
ariel's user avatar
  • 1
0 votes
0 answers
12 views

How to migrate application pinned cert to Unpinned cert in Scope VCclient

As security request, we need to migrate application pinned cert to Unpinned cert. unpinned cert sample code is below X509Certificate2 certificate = new X509Certificate2(@"C:\Certificates\...
Shuai's user avatar
  • 21
-2 votes
0 answers
60 views

how to pass variable to another method?

I'm trying to write a basic robot function that moves servo when buttons are pressed. I can capture button state changes successfully. The problem is I can't access the servo variable (device) in the ...
WestMansionHero's user avatar
0 votes
1 answer
31 views

Maven ${project.version} scope

I have parent pom with dependency management declared by ${project.version}. Then I inherit parent in my target project, this project has other version than parent. This throws errors, because of ...
Cezary's user avatar
  • 33
-1 votes
1 answer
44 views

let scope in javascript

I wanted to know if someone can explain the working of scope with respect to let keyword. import "./styles.css"; import { useEffect, useReducer, useState } from "react"; export ...
Abhishek Kumar Singh's user avatar
0 votes
1 answer
49 views

What forms a scope in javascript? [duplicate]

While reading about 'this' keyword and arrow function, I read: that arrow functions binds to whatever execution context the surrounding scope has. I have attached a simple code example below. When I ...
aarshin gupta's user avatar
1 vote
2 answers
71 views

How does Java handle memory with regards to homonymous local variables declared inside different not-nested code blocks inside a method?

I'm new to Java and programming in general. I'm currently studying how Java handles variables' memorization and scope. What I've understood is that: local variables (i.e. variables declared inside ...
Ignis's user avatar
  • 13
0 votes
0 answers
31 views

Using 'this' in custom Phaser classes

I'm working on an old school RPG using Phaser.js. I have what I know is a simple question. In my custom classes almost all have: export default class Chest extends Phaser.Physics.Arcade.Sprite{ ...
maddogandnoriko's user avatar
0 votes
2 answers
43 views

NameError when accessing variable returned from function (out of order?)

Per the code below, I'm getting this error: NameError: name 'leap_status' is not defined The def days_in_month() is looking for the status of leap_status which should be defined already but, for ...
J W's user avatar
  • 5
0 votes
1 answer
36 views

How can I return data from preloaded Electron script?

I have built a function in preload.js that gets a JSON file sent from main.js. renderer.js loads it fine, but I can't seem to give the data to another variable outside of the arrow function. main.js ...
liminalFrog's user avatar
0 votes
1 answer
53 views

Positional arguments in nested functions

This question relates to this video: https://www.youtube.com/watch?v=jXugs4B3lwU The piece I'm missing is somewhat simpler than the concept the video is covering overall. In the example code below: ...
Chris's user avatar
  • 424
0 votes
1 answer
18 views

TLE on coin combinations 1 cses

can someone tell why the following code for coin combinations 1 question from cses problemset is getting time limit exceeded #include <bits/stdc++.h> #define int long long using namespace std; ...
Aryan phad's user avatar
0 votes
3 answers
126 views

Are global variables still slower than local variables in modern JavaScript engines?

I recently read "High Performance JavaScript" (2010) which states: The deeper into the execution context’s scope chain an identifier exists, the slower it is to access for both reads and ...
narutoshippuden's user avatar
2 votes
1 answer
59 views

Are there any risks to accessing internal functions with :: or :::?

I've been developing a package in R which has a number of functions (some exported, some not) which are used by other functions in the package. Since the package loads and attaches itself, is there ...
divibisan's user avatar
  • 12k
3 votes
4 answers
140 views

Structures declared in function prototypes

I have two functions. pos(), which defines a struct as its return type, and bar(), which defines a struct as an argument type: #include <stdio.h> #include <stdlib.h> static struct foo { ...
Harith's user avatar
  • 7,210
-1 votes
2 answers
72 views

I don't know how to make my code work correctly [closed]

I was practicing and I tried defining mathematical functions and other stuff, but then I got a bunch of errors and I ended up not having an error but the result was wrong. This is the code as of ...
MistyKing's user avatar
2 votes
2 answers
74 views

when a variable has no value initialised in local scope it seaches value global scope

#include<stdio.h> static int i=27; int main() { static int i; printf("%d",i); } The output of this program is 0 as the local scope has auto initialized 0 as i empty but should'nt ...
Dhanush G's user avatar
0 votes
1 answer
18 views

Incrementing Key in Simple React To Do App

I have an incrementing key in my React To Do App so I can filter out certain tasks with an id identifier. For some reason, I have to declare and define my id outside of the main function. Why can't I ...
Shuumi's user avatar
  • 25
0 votes
0 answers
21 views

How to take care of a "dynamic" object in an IF-ELSE-loop in C#?

I have the following C#-code: while (...) { ...(out var information); dynamic obj = JsonConvert.DeserializeObject(information); if (obj.Some_Property != null) { As you see, it ...
Dominique's user avatar
  • 17.2k
0 votes
0 answers
13 views

Tool/extension for scanning variable references across multiple js files in aspx project

I need to fix the Critical and Blocker issues in the Sonarqube for the aspx project. It contains several (around 500) js files. Sonar is flagging issues in js files that variables should be ...
Saurav Yadav's user avatar
1 vote
2 answers
60 views

Scope of an entry added to a c++ set?

Let's say I have a globally scoped set defined as follows: std::set<Person> people; I also have a function where I create an instance of the class Person, and add it to the set as follows: void ...
SimpleCoder's user avatar
  • 1,223
0 votes
0 answers
29 views

Variable visibility in python [duplicate]

Maybe a stupid question but I'm new to python. The following code throws an error: deck = [10, 2, 5, 8, 2, 7] deck_idx = 0 def deal(): card = deck[deck_idx] deck_idx += 1 return card print(...
Disti's user avatar
  • 1,444
0 votes
0 answers
16 views

In IdentityServer4 is there a way to add the client GUID available in the ExtendedClients table in claim list?

I would like to identify a client using the GUID available in the ExtendedClients table. When a client requests a token using the client_credentials flow, the claim available in the token is the ...
Cristian Zambiasi's user avatar
1 vote
2 answers
88 views

How to simulate a beacon on one smartphone and to detect it on a second smartphone generating a automatic notification (all with existing apps)

I would like to use a old smartphone to simulate a beacon and leave it at home always charged just for this purpose. I would like to detect it automatically on my personal new smartphone and get a ...
Domenico Pozzetti's user avatar
0 votes
2 answers
54 views

Why can I redeclare a variable of the same name as a function parameter within an if statement?

Below is a trivialized version of a solution I came across while trying to implement a version of the Jquery CSS function. function CSS(prop, value) { ... if (value === undefined) { ...
GHOST-34's user avatar
  • 378
0 votes
0 answers
50 views

How can I create a scope isolated from parents and globals other than using the `with` statement over a Proxy?

I'm trying to reset the scope, as in hide all variables except a select few, in JavaScript. I know I can use the with keyword and a proxy, but it is deprecated and not allowed in strict mode. As far ...
TwiceUponATime's user avatar
1 vote
3 answers
84 views

How does one access the arguments of a function call when this function can not be rewritten due to its unknown implementation?

I have a function-returning function. The inner function makes use of the parent function's argument in its body. Then I make a list of functions produced by calling the parent function with different ...
burkay's user avatar
  • 1,135
1 vote
0 answers
42 views

CDI Custom Scope not working with WELD-001303 error

I have Jetty project (Jetty embedded based version 11) with JPA, CDI, JMS & JAX-RS project. Everything works good, however I want to add a new scope @Inherited @NormalScope @Retention(...
Shay Zambrovski's user avatar
0 votes
1 answer
44 views

Javascript, Call a nested function from outside the function or call it from inside another function

Is it possible to call a function that is nested inside a function from either outside of the original function or from inside another function? So in the example when the func_1 is called the first ...
London28's user avatar
  • 101
1 vote
1 answer
42 views

Is there a way to access all enumerations in a enum class with a using directive or similar? [duplicate]

I have a enum class which is used to clearly store the kinds of tokens which are passed into a parser for a calculator. The enum class looks like this: enum class TokenKind { Number, ...
user3612's user avatar
  • 353
1 vote
1 answer
24 views

Scope of identifiers in R formulas/expressions

I'm using as.ggplot from ggplotify to wrap some chord diagrams from the circlize package so I can arrange them nicely using patchwork. However, since as.ggplot takes a formula or expression as an ...
Luther Blissett's user avatar
0 votes
0 answers
19 views

How to let typescript infers type of `this` in nested scope? [duplicate]

I use typescript v5.4.5 (playground) and have an issue. There is my code example function wrapper<C>(ctx: any, fn: (r: any) => void) { const r = {}; return fn.call(ctx, r); } class ...
Nguyen Anh Tuan's user avatar
0 votes
4 answers
101 views

How to write Rails scope for this SQL query

I have an issue to get rows from database by multiple conditions. I have a table Slot and SlotAlteration. The slot has a time_off_id field. SlotAlteration has two columns, slot_id and action. Action ...
RomanMin's user avatar
1 vote
0 answers
23 views

Accessing function with the same name outside the local scope [duplicate]

I have a dart file (integers.dart) with the following function: int max(int a, int b) => a > b ? a : b; The file also has the following extension, which won't compile: extension MyIterable on ...
Martin East's user avatar
0 votes
1 answer
175 views

QuarkusContextStorage Context in storage not the expected context

While using telemetry with quarkus, we are seeing the below message flooding our logs. io.quarkus.opentelemetry.runtime.QuarkusContextStorage~INFO~~~[executor-thread-26]~Context in storage not the ...
sg2000's user avatar
  • 97
1 vote
2 answers
55 views

Scope of for loop counter in Visual Basic

Consider the following Dim nofTries As Integer For nofTires = 1 To 5 If (condition) Then Exit For Next Where due to a typo the loop counter is different than the variable declared. Yet, despite ...
Ernesto's user avatar
  • 35
0 votes
1 answer
110 views

How to get datadog application key scopes

I'm trying to access multiple datadog apis and to access them I require the api and application key of the datadog. But is there any way to check the scopes or the permissions of the application key ...
Tushar Agarwal's user avatar

1
2 3 4 5
353