scoping

What is the difference between my and local in Perl?

I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me? ...

Scoping issue in Javascript

Hi All, I need to have some information about the Scoping issue in Javascript. I know that it spports lexical(static) scoping, but, does not it support dynamic scoping as well? If you know anything about the scoping in Javascript, would you please share them with me ? Thanks ...

Can I use blocks to manage scope of variables in C++?

Hi, I'm trying to gain some memory saving in a C++ program and I want to know if I can use blocks as a scope for variables (as in Perl). Let's say I have a huge object that performs some computations and gives a result, does it makes sense to do: InputType input; ResultType result; { // Block of code MyHugeObject mho; resu...

scoping of private variables in object prototype methods

This question is about the behavior of an object with methods added to its prototype chain and a few private variables. Just out of curiosity and to get my head around this riddle. function SomeObject() { if (this instanceof SomeObject) { var args = arguments[0], proto = SomeObject.prototype, privatevalue ...

Python variable assigned by an outside module is accessible for printing but not for assignment in the target module

I have two files, one is in the webroot, and another is a bootstrap located one folder above the web root (this is CGI programming by the way). The index file in the web root imports the bootstrap and assigns a variable to it, then calls a a function to initialize the application. Everything up to here works as expected. Now, in the bo...

Scoping problem in Ada

I got this problem wrong on my homework, and I can't figure out why: procedure Main is X: Integer; procedure Sub1 is X: Integer; begin - of Sub1 Put(X); end; - of Sub1 procedure Sub2 is X: Integer; begin - of Sub2 X:=5; Sub1 end; - of Sub2 begin -of ...

Oracle - How to have an out ref cursor parameter in a stored procedure?

The standard way that our applications pass information from oracle stored procedures to the oracle .net provider is via an out ref cursor parameter. In the past all of our stored procedures used to be in packages and had something like this: CREATE OR REPLACE PACKAGE test_package IS TYPE refcur IS REF CURSOR; PROCEDURE get_info ...

Are variables statically or dynamically "scoped" in javascript?

Or more specific to what I need: If I call a function from within another function, is it going to pull the variable from within the calling function, or from the level above? Ex: myVar=0; function runMe(){ myVar = 10; callMe(); } function callMe(){ addMe = myVar+10; } What does myVar end up being if callMe() is called t...

Javascript closure scoping issue

I'm trying to get a reference to cell and it appears null. If I'm understanding it correctly, I should be able to reference the variable. Correct? $('td[someAttr]').mouseenter(function(cell) { var timeoutId = setTimeout(function() { // what should variable cell be? }, 1000); }); OR $('td[someAttr]').mouseenter(functi...

What methods are there to modularize C code?

What methods, practices and conventions do you know of to modularize C code as a project grows in size? ...

Python scoping problem

I have a trivial example: def func1(): local_var = None def func(args): print args, print "local_var:", local_var local_var = "local" func("first") func("second") func1() I expect the output to be: first local_var: None second local_var: local However, my actual output is: first local...

Namespacing/Scoping in CSS

I want to apply the rules in a CSS file to a certain div/class so, for example, the contents of events.css is only applied to the contents of a class called .events and not outside this scope without the need to add the class .events to the start of each css rule. I am thinking this is not possible though - but you never know. If not I...

Dynamically scoped variable in java ? (a.k.a one variable per method execution)

hi, I would like to know if it's possible in java to declare a variable local to the execution of the method. For instance, if i'm doing some recursive stuff and i want to keep various counters specific to one particular execution of the method. I don't know the correct english expression for that... ...

capacity scoping

how to perform a capacity scoping for sql server ? ...

VBScipt: Call builtin functions shadowed by global variables

VBScript on ASP Classic contains an "int" function. (It rounds numbers towards -∞.) Suppose that some excessively "clever" coder has created a global variable named "int". Is there any way to get at the original function? I've tried all manner of workarounds with scoping and dodgy execs, but no dice. I suspect that it is impossible, but...

how to get an anonymous function to keep the scoping it had originally when called in an event handler

I have a setup where I get some information, in an ajax call, then I immediately use some of that information for another call, and then I populate some fields. The problem is that I am not certain how to create the anonymous function so that it can call this.plantName. Right now the value of this.plantName is undefined. I know that t...

variables scoping when inheriting

I have two classes in C++, where one inherits from the other: class A { public: virtual void Initialize(){ m_MyString = "Default value"; } protected: string m_MyString; } class B : public A { public: void Initialize(){ A::Initialize(); m_MyString = "New Value"; } } Is there a differenc...

Dynamic Scoping - Deep Binding vs Shallow Binding

I've been trying to get my head around shallow binding and deep binding, wikipedia doesn't do a good job of explaining it properly. Say I have the following code, what would the output be if the language uses dynamic scoping with a) deep binding b) shallow binding? x: integer := 1 y: integer := 2 procedure add x := x + y procedure...

Scala Newb Question - about scoping and variables

Hi, I'm parsing XML, and keep finding myself writing code like: val xml = <outertag> <dog>val1</dog> <cat>val2</cat> </outertag> var cat = "" var dog = "" for (inner <- xml \ "_") { inner match { case <dog>{ dg @ _* }</dog> => dog = dg(0).toString() case <cat>{ ct @ _* }</cat> => cat = ct(0).toString() } } /* do somethin...

In a web site, Where do you declare project-scope enums ?

Hi all In an asp.net web site project, Where do you declare project-scope enums ? ...