scope

Does C supports scope resolution? [duplicate]

瘦欲@ 提交于 2020-01-05 09:28:05
问题 This question already has answers here : How can I access a shadowed global variable in C? (7 answers) Closed 5 years ago . #include <stdio.h> /* global variable declaration */ int g = 20; int main () { /* local variable declaration */ int g = 10; printf ("value of g = %d %d\n", g,::g); return 0; } When i am trying to run this program. It is throwing error main.c:11:39: error: expected expression before ':' token printf ("value of g = %d %d\n", g,::g); . But if it is written in C++, it works

How to understand dynamic scoping using Python code?

冷暖自知 提交于 2020-01-05 09:27:55
问题 I'm a programmer coming from Python background which typically uses lexical scoping and I want to understand dynamic scope. I've researched it on-line, still unclear to me. For example, I've read this page which made things a lot easier to me, especially the code snippets: #In Dynamic scoping: const int b = 5; int foo() { int a = b + 5; return a; } int bar() { int b = 2; return foo(); } int main() { foo(); // returns 10 bar(); // returns 7 return 0; } #In lexical scoping: const int b = 5; int

How to understand dynamic scoping using Python code?

旧时模样 提交于 2020-01-05 09:27:09
问题 I'm a programmer coming from Python background which typically uses lexical scoping and I want to understand dynamic scope. I've researched it on-line, still unclear to me. For example, I've read this page which made things a lot easier to me, especially the code snippets: #In Dynamic scoping: const int b = 5; int foo() { int a = b + 5; return a; } int bar() { int b = 2; return foo(); } int main() { foo(); // returns 10 bar(); // returns 7 return 0; } #In lexical scoping: const int b = 5; int

How could I search references to a field on a AST or a CompilationUnit in eclipse?

会有一股神秘感。 提交于 2020-01-05 08:42:32
问题 Hi, I'm developing an Eclipse plugin. I need to find all the references in the source using AST's or jdt.core.dom or something like that. I need this references like ASTNodes in order to get the parent node and check several things in the expression where references are involved. Thanks beforehand. Edited: I want to concrete a little more, My problem is that I try to catch some references to a constant but... I have not idea how I can do to catch in the matches this references. I need check

Functions Scope in JavaScript

こ雲淡風輕ζ 提交于 2020-01-05 08:34:47
问题 In Pro JavaScript with Mootools book I have found the below line The scoping rules for function expressions are a bit different from function declarations because they depend on variable scoping. Remember that in JavaScript, the var keyword defines a variable to be scoped locally, and omitting the keyword creates a global variable instead: As per my understanding I have written the below code and tried to check this var a = function(){ b = function(){ c = function(){ alert("b"); }; }; };

Writing to locals() works in contrast to documentation saying its not

心不动则不痛 提交于 2020-01-05 08:18:12
问题 I am currently tinkering with the variable scopes and how they can be modified / copied, as I would like to postprocess some results dynamically in IPython. The confusion about locals(), vars() and globals() is real for me right now. Especially because the output of this piece of code: Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> locals()["test"] = 5 >>>

Testing Emberjs app using QUnit and Karma fails due to `ReferenceError: Faye is not defined`

旧时模样 提交于 2020-01-05 07:46:38
问题 I Was testing EmberJs application with Qunit and karma runner and it was working all good. Then I had to integrate faye into the application which went well but then on running my test suite, it shows following error and crashes: ReferenceError: Faye is not defined The error is thrown where, I am defining the client in emberjs client = new Faye.Client(uri); Though this works in development, staging but not in testing. Overhere, uri = "http://localhost:9292/faye" faye.js is included in vendor

java namespace collisions

梦想的初衷 提交于 2020-01-05 07:42:12
问题 I find myself frequently making the following error. public class Foo{ Bar bar; public void doSomething(){ Bar bar = makeNewBar(); // bla bla } } where the error is that I want to set Foo's bar, not a local Bar. I.e, I should say bar = makeNewBar() , not Bar bar = makeNewBar() . Is there a compiler warning flag or something that can detect "namespace collisions" like this? If not, what's a good way to avoid this (short of not making the error, which is obviously the best option =p)? 回答1: That

Scope and Namespace questions

[亡魂溺海] 提交于 2020-01-05 07:29:33
问题 I was examining various JavaScript libraries for learning purposes. Basically I want to find the best way to initiliaze a namespace and see how pros load up all the associated files in their libraries. I came across this a few times in the main file (for example lets call it myNameSpace.js) that the library user would call in a few libraries: (function() { var jsFiles = window.MyNameSpace; window.MyNameSpace = { _getScriptLocation: (function() { /* some code here */ }) }; if(!jsFiles) {

How to access a specific $scope variable when loading a different .html file?

情到浓时终转凉″ 提交于 2020-01-05 06:43:45
问题 First of all, sorry about the title, I just wan't sure how to word this question. So I'm making a task manager using AngularJS. I have a form for the user to fill with the details when he's creating a new task. I use ng-model to save these values to my $scope . Here's how I save them: $scope.add = function(tasks) { { $scope.tasks.push({ 'id': tasks.id, 'title': tasks.title, 'start_day': tasks.start_day, 'start_time':tasks.start_time, 'start_date':tasks.start_day + " " + tasks.start_time, 'end