Now, before you jump at how you shouldn't mix scopes: I realize this. However, this is a case where either scope mixing must occur or major code duplication must occur—nothing around it. And I'd prefer scope mixing.
That said, I'd like this code:
function a() {
$a = "a";
$b = "b";
$c = "c";
}
function b() {
a();
ech...
Hi, I need to combine name scope with or operator...
Something like:
class Product < ActiveRecord::Base
belongs_to :client
scope :name_a, where("products.name = 'a'")
scope :client_b, joins(:client).where("clients.name = 'b'")
scope :name_a_or_b, name_a.or(client_b)
end
Thx
...
OK, it's probably easiest now to explain my problem like this, I am able to write the name of my xml file that needs to be loaded to a dynamic textfield on the stage, however, I don't seem to be able to access it after this and strip the necessary data from it, here's my code:
var tf:TextField = new TextField();
tf.autoSize=TextFieldAut...
The descriptor protocol in Python 2.6 is only defined for class definitions, and thus can only be used by instances.
Is there some equivalent for instrumenting get/set of globals?
I'm trying to speed up the importing of a module which interacts with the host system, and as such has to perform some expensive probing of the host. The res...
window.global_array = new Array();
window.example = function()
{
var x = new Object();
x['test_property'] = 3;
global_array.push(x);
}
Javascript gurus, please answer three questions:
will javascript delete x at the end of scope when example() returns, or preserve it inside global_array.
can I safely assu...
Hello,
I am having an issue in php... I don't fully understand how the whole require() thing works. My understanding is that it takes the current class's member variables and makes them global inside the required file. If this is the case, then why does it not also take the base class's member variables and make them global?
basecla...
I have read a number of explanations about closures and closures inside loops. I have a hard time understanding the concept. I have this code: Is there a way to reduce the code as much as possible so the concept of closure can be made clearer. I am having a hard time understanding the part in which the i is inside two parenthesis. Thanks...
I'm using twisted with GTK, and the following code runs when a connection could not be established:
def connectionFailed(self, reason):
#show a "connect failed" dialog
dlg = gtk.MessageDialog(
type=gtk.MESSAGE_ERROR,
buttons=gtk.BUTTONS_CLOSE,
message_format="Could not connect to server:\n%s" % (
...
Hi!
Can you give me some examples of tasks unsuited for dynamically scoped lisps? I'm failing to see how the Lexical scope is so much better and not just a matter of changing the coding style, so I'd love to code something and see it with my own eyes.
Thanks!
...
I have a Python script 'runme.py' that I am trying to execute from 'callerX.py' below. I am using exec(open(filename).read()) to accomplish this task. The script being executed contains a simple class that attempts to call the 'time()' function both from the global namespace & inside a function.
In all of the examples below, we are exec...
I wrote this simple python program to help me with a bug in another program. It clearly illustrates the problem.
import copy
class Obj(object):
def __init__(self, name):
self.name = name
def one(o):
print("1: o.name:", o.name) # "foo"
obackup = copy.deepcopy(o)
o.name = "bar"
print("2: o.name:", o.name) #...
I have namespace with enums:
namespace Search
{
enum SearchConditionType
{
Like = 0,
EqualNotString = 1,
EqualString = 2
};
}
Then I try to declare enum:
namespace Search
{
public partial class Controls_SelectYesNo : System.Web.UI.UserControl
{
public SearchConditionType Field;
...
I just read this question: http://stackoverflow.com/questions/3585073/why-are-different-case-condition-bodies-not-in-different-scope
It's a Java question, but my question applies to both C# and Java (and any other language with this scope reducing feature).
In the question, OP talks about how he knows he can manually add in {} to refin...
Hi,
I use the $.post function to submit an ajax request as such:
$('.typeAform').submit(function(){
$.post('/home', { somevar : 'somevalue' }, function(){
//do something with the original form
});
return false;
});
I'd like to identify my form after submission from the $.post callback so I can do something with it...
Hello All
I have a question which I cannot seem to fathom out, as fairly newish to c++. I have a class, in which a set of variables are declared in the .h file and then initialised in the .cpp file. These same variables are used by a set of 3 other classes - and the compiler has them as out of scope. I am not sure how to link the classes...
Is it legal to replace something like this:
namespace foo {
namespace bar {
baz();
}
}
with something like this:
namespace foo::bar {
baz();
}
?
...
Hey, everyone!
I'm totally confused with this small "out of scope" thing.
So here is some code to describe my situation:
Simple iphone view-based application.
View controller header:
#import <UIKit/UIKit.h>
@interface global_nsstring_testViewController : UIViewController {
UIImageView* image_view;
NSString* image_name;
}
@propert...
I have an ErrorLog class, that is used to write and modify log files. I'd like to write to it before and after major events for debugging purposes and I only want to use one instance of the ErrorLog class for the entire application. I tried declaring an ErrorLog object as a global by placing ErrorLog exe_log; into a header file so it is ...
I'm going through the problems in the Haskell O'Reilly book. The problem I am working on is
Using the binary tree type that we defined earlier in this chapter, write a function that will determine the height of the tree. The height is the largest number of hops from the root to an Empty. For example, the tree Empty has height zero; Nod...
I am have a problem with creating a server push network object. Because Firefox and chrome handle server push differently, (Firefox get onload events, chrome uses onprogress /broken ). For chrome I need to capture the onprogress events and then mask off the previous data from the responseText. I want to pass just the new data to chrome. ...