scoping Questions
6
Solved
Possible Duplicate:
Can I use blocks to manage scope of variables in C++?
I came across some C++ code that resembled:
int main(void) {
int foo;
float qux;
/* do some stuff */
{...
Cero asked 3/11, 2012 at 3:15
1
Solved
>>> x = 'foo'
>>> {0: locals().get('x')}
{0: 'foo'}
>>> {0: locals().get('x' + spam) for spam in ['']}
{0: None}
What is the reason for this discrepancy in behaviour?
2
Solved
Recently I've been doing things like this:
import Tkinter
class C(object):
def __init__(self):
self.root = Tkinter.Tk()
def f():
print 'hello'
self.button = Tkinter.Button(master=self.root, c...
Lierne asked 4/9, 2012 at 15:53
4
Solved
Bjarne suggests using the condition in if's as scope restriction. In particular this example.
if ( double d = fd() ) {
// d in scope here...
}
I'm curios how to interpret the declaration in a ...
Conceptacle asked 26/6, 2012 at 23:6
1
Solved
An R namespace acts as the immediate environment for all functions in its associated package. In other words, when function bar() from package foo calls another function, the R evaluator first sear...
Alwin asked 12/6, 2012 at 20:6
3
Solved
Out of just intellectual curiosity, why does javascript accept
var z = z || [];
to initialize z (as z may defined initially)
but without var, it throws an error (in global space)
z = z || [];...
Westphal asked 30/1, 2012 at 16:0
3
First I'm going to start like everyone else. I'm new to python. My teacher gave me the problem:
def f(a, b, c):
a = 1
c = b
c[0] = 2
a = 10
b = [11, 12, 13]
c = [13, 14, 15]
f(a, b, c)
...
Mulch asked 6/12, 2011 at 21:23
3
Solved
I have a very large List of numbers, which undergo lots of math manipulation. I only care about the final result. To simulate this behavior, see my example code below:
object X {
def main(args:Ar...
Yet asked 25/11, 2011 at 19:30
1
Solved
EDIT: I changed the example code after the first answer because I came up with a simple version that begs the same questions.
I am currently learning Common Lisp's scoping properties. After I thou...
Canzone asked 16/10, 2011 at 22:8
1
I have been trying to eager load associations based on some scope in my rails3 app, but could not find any solution.
My app has following models:
class Project
has_many :entries
has_many :to_do...
Microtone asked 18/7, 2011 at 5:11
5
I wrote this code:
x = 0
def counter():
x = 1
def temp(self):
print x
x += 1
return temp
Trying to test if python is lexical or dynamic scope. My thinking was that
y = counter()
y()
Sho...
3
if arguments.callee is not allowed in "use strict", and we can't do
var f = function g() {
//g
}
because in IE that wouldn't work (or that would work "weirdly") http://kangax.github.com/nfe/#js...
Dominican asked 22/4, 2011 at 16:17
1
Solved
I have a question on the scope of dot-dot-dot arguments. Consider the following function`foo =
foo <- function(x, ...){
require(classInt);
intvl = classIntervals(x, ...);
return(intvl);
}
...
2
Solved
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 functio...
4
Solved
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 t...
Yevetteyew asked 1/10, 2010 at 15:43
3
Solved
I have a Javascript "class" defined like so:
var Welcomer = function(name) {
var pName = name;
var pMessage = function() {
return "Hi, " + pName + "!";
};
return {
sayHi: function() {
aler...
Bebe asked 24/8, 2010 at 21:27
1
Solved
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 sam...
7
Solved
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 varia...
5
Solved
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 unders...
8
What methods, practices and conventions do you know of to modularize C code as a project grows in size?
Neonatal asked 22/7, 2009 at 3:10
1
Solved
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) {
va...
Setback asked 25/6, 2009 at 21:23
4
Solved
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 a...
2
Solved
I need to have some information about the scoping in JavaScript. I know that it supports lexical (static) scoping, but, does not it support dynamic scoping as well?
Brooch asked 29/11, 2008 at 11:40
© 2022 - 2024 — McMap. All rights reserved.