scoping

Why does using the same count variable name in nested FOR loops work?

Why does the following not give an error? for (int i=0; i<10; ++i) // outer loop { for (int i=0; i<10;++i) // inner loop { //...do something } //...do something else } The way I understand it, variables in braces ({...}) are in scope only within these braces. But the inner loop is inside the braces of the outer loop. S...

Why can't my Perl subroutine see the value for the variable in the foreach loop that called it?

I hope this is something straightforward that I'm doing wrong. I saw something online about "variable suicide" that looked good, but it was for an older version and I'm on 5.10.1. Anyway - a variable that I declared - $RootDirectory - just suddenly loses its value, and I can't figure out why. Here's a script to reproduce the problem....

Why isn't my Ruby object deleted when the last reference goes out of scope?

Hi gurus, I've found a weird effect when trying to track down a memory leak in a Rails app. Can anyone explain what's going on here? Save this script as a plain Ruby script (Rails not necessary): class Fnord def to_s 'fnord' end end def test f = Fnord.new end test GC.start sleep 2 ObjectSpace.each_object do |o| ...

scoping document for Sharepoint.

How to prepare the scoping document for the Sharepoint ? Any good tips and links to the example documents will be appreciated. Thanks ...

How do you use "<<-" (scoping assignment) in R ?

Hi all, I just finished reading about scoping in the R intro, and am very curious about the <<- assignment. The manual showed one (very interesting) example for "<<-", which I feel I understood. What I am still missing is the context of when this can be useful. So what I would love to read from you are examples (or links to examples) ...

Scope of Derived Tables in SQL Server

I've been looking into SQL recently and exploring a bit. in regards to Temp Tables I have discovered 3 different temp table types: 1) CREATE TABLE #TempTable 2) DECLARE TABLE @TempTable 3) SELECT * FROM (SELECT * FROM Customers) AS TempTable Now I understand the scope behind the #TempTable and the @TempTable types, but what about the...

How does scoping work in Perl modules?

I don't really understand how scoping works in Perl modules. This doesn't print anything. I would like it if running a.pl printed 1 b.pm $f=1; a.pl use b; print $f ...

When designing a web project, how should use statistics be incorporated?

Suppose you are taking notes on the requirements of an app enhancement for software that sells products X1 - X100 on the internet. The marketing people have a laundry list of features that the software should be able to do, but aren't mentioning things like reporting, feature interoperability, or version testing. In the same way that y...

Why can't I bind things like EMAIL! in the global context on interpreter startup?

When I start up an R3 Alpha 99 session, and enter this as the first command, I get an error: >> is-email-addr: get bind to-word "email?" bind? 'system ** Script error: email? is not in the specified context ** Where: bind ** Near: bind to-word "email?" bind? 'system But if I quit, restart and instead execute a test to prove that the e...

Lambda variable scope

Example: myObject.Stub(s => s.MyMethod(null)).IgnoreArguments().Return("bleh"); var s = "s"; A variable "s" is defined in a lambda and another variable "s" as a local variable within the same method. Visual Studio tells me "A conflicting variable is defined below" when I hover over the first "s". Why are these conflicting; the "s" in...

Can I "extend" a closure-defined "class" in Javascript?

I have a Javascript "class" defined like so: var Welcomer = function(name) { var pName = name; var pMessage = function() { return "Hi, " + pName + "!"; }; return { sayHi: function() { alert(pMessage()); } }; }; new Welcomer('Sue').sayHi(); Is there a way to "subclass" Welcomer in such a way that I can red...

Python scoping and threading question

I have one thread that inserts into the queueStream (not shown here) and FlowController which is another thread that pops from the queue if the queue is not empty. I verified that the data is inserted into the queue correctly with the debug code in addToQueue() Problem is, the 'if queueStream' statement in FlowController always sees th...

What should go into class declarations in header files?

What should go into a class declaration in C++? For example, I have the following in a header file: class BoardState { public: BoardState(); bool HasWon() const; bool HasMoves() const; bool MakeMove(const int column); bool UndoMove(const int column); const Chip (&grid() const)[kGridHeight][kGridWidth] { return grid_; } ...

Scoping and functions in R 2.11.1 : What's going wrong?

This question comes from a range of other questions that all deal with essentially the same problem. For some strange reason, using a function within another function sometimes fails in the sense that variables defined within the local environment of the first function are not found back in the second function. The classical pattern in ...

How can I make an instance of a class created in one method available to another peer method?

Is there any way to be able to create multiple class objects based on how many the user wants created? I was able to do this but then that instance is only available under the method that created it public void Create() { //create class objects here } and now I wouldn't be able to use it in another method for examp...

Scoping problem when sfApply is used within function (package snowfall - R)

Let me add another scoping problem in R, this time with the snowfall package. If I define a function in my global environment, and I try to use that one later in an sfApply() inside another function, my first function isn't found any more : #Runnable code. Don't forget to stop the cluster with sfStop() require(snowfall) sfInit(parallel=...