scope

Is there a way to see all variables in the current scope?

Title kinda asks it all. I'm not referring to $_REQUEST, $_SERVER and all the pre-defined. I just want to know if on line 400 of my program I can somehow see all the variables that have been created up to that point. Duplicate of: http://stackoverflow.com/questions/717852/php-get-all-variables-defined-in-current-scope-symbol-table ...

Will this be out of scope and not function properly?

I'm declaring a struct inside my code and then trying to insert it into a data structure that I have written. However, I'm concerned that since I declare the struct inside the function, once the function ends, the data structure will be pointing to garbage. Can anyone help with this? Here's the code: void Class::function() { // do ...

Should you refactor code into private methods if they aren't called more than once?

Is it worth extracting private methods for code that only gets called once in a class, or leaving the code in the parent method (maybe) with a comment that says what it does? ...

How to always set a value for account-scope in Rails?

Hi, I'm working on a multi-user, multi-account App where 1 account can have n users. It is very important that every user can only access info from its account. My approach is to add an account_id to every model in the DB and than add a filter in every controller to only select objects with the current account_id. I will use the authori...

Inline functions and other method's scope.

How do I make the myFunction visibile for the in-line function in .ready() event? $(document).ready(function() { ...stuffs... myFunction(par1, par2, anotherFucntion_callback); } ); function anotherFunction_callback(data) { ..stuffs.. } ...

Singleton, Logging and Global Settings - Good or Bad implementation?

I've got a logging class which requires need to be called from almost everywhere in the application. However it requires setup in the beginning of the application with "which path to write", "log level" and if it's "enabled" or not. I don't want to give this parameters every time or pass Logging class as parameter to every single objec...

C#: Limit global field's scope to method / property OR preserve method's / property's local variable's value between calls

Hi, I often have methods which are called regularly and have some "state" which has to be preserved between calls, as in: float lastTime = 0.0f; void Draw( float currentTime ) { if( currentTime - lastTime > 0.5f ) { // not enough FPS } lastTime = currentTime; } And it drives me nuts that the global "state" f...

Scope of anonymous methods

One nice thing about anonymous methods is that I can use variables that are local in the calling context. Is there any reason why this does not work for out-parameters and function results? function ReturnTwoStrings (out Str1 : String) : String; begin ExecuteProcedure (procedure begin Str1 := ...

problem in itemClick

if (theData.hasOwnProperty("@id1")) { var myObj:Hello = new Hello(); textArea.visible = false; panel.addChild(myObj); } else if (theData.hasOwnProperty("@id2")) { textArea.visible = false; var vijay:MCQ = new MCQ(); panel.addChild(vijay); } When i click on the next item, the previous window is sti...

Scope Of ASP.Net Variables

I'm having a bit of a weird problem to do with scope of variables. I've declared a variable in the following way: public partial class MyClass: System.Web.UI.Page { protected static int MyGlobalVariable; protected void MyFunction() { MyGlobalVariable = 1; } } And this works fine on the workings of my page. How...

member template specialization and its scope

It appears to me that C++ does not allow member template specialization in any scope other than namespace and global scope (MS VSC++ Error C3412). But to me it makes sense to specialize a base class's primary member template in the derived class because that is what derived classes do - specialize things in the base class. For instance, ...

What scope does an "at" sigil (@) give within Ruby functions?

It's been a while since I last did Ruby programming -- looking at somebody else's code, I see the @ sigil in a function (not a method -- external to any class definition), which I understood to be scoped to instance members. Is the module the implied self in functions? ...

Scope of Python Recursive Generators

Hey all, I was working on a recursive generator to create the fixed integer partitions of a number and I was confused by a scoping issue. The code is similar to this snippet. def testGen(a,n): if n <= 1: print('yield', a) yield a else: for i in range(2): a[i] += n for j in testGen...

Getting local dictionary for function scope only in Python

I keep ending up at this situation where I want to use a dictionary very much like the one 'locals' gives back, but that only contains the variables in the limited scope of the function. Is there a way to do this in python? A bit more about why I want to do this: I'm playing with Django and when I go to give my templates context, I am ...

How do I call static variable in a separate class in PHP?

How can I access a static variable in a separate class in PHP? Is the scope resolution operator the wrong tool for the job? Example: class DB { static $conn = 'Connection'; } class User { function __construct() { DB::conn; //throws "Undefined class constant 'conn' error. } } ...

Allow the user to pick a named scope via GET params

In my posts model, I have a named scope: named_scope :random, :order => "Random()" I'd like to give users the ability to get posts in a random order by sending a GET request with params[:scope] = 'random'. Short of eval("Post.#{params[:scope]}"), how can I do this? ...

JSP useBean scope question

Hi there, I have 4 JSP pages index.jsp - default index webpage. Index.jsp includes the build.jsp to initialize the web service as well as the header.jsp (to display the form with the dropdown element. Users can select a value from this form and submit the form to formControl.jsp.) build.jsp - This jsp is included in index.jsp before th...

JSP useBean Request scope question

Hi there, I am setting the values of a java bean from a jsp page which has the useBean scope of request. Does this mean that the java beans will lose their value once a user navigates away from this page? ...

Can I have an application scope variable in Perl?

Hello everybody, I'm somewhat new to Perl/CGI, and I'm coming from a Java/JSP background. I'm writing a small prototype and need to load some "heavy" data (~200MB) into a data structure. Now, I'd obviously like to avoid loading the data with every request. So far I managed to use a "static" variable (one enclosed in a {} block), but t...

Using a dictionary object in application scope in Classic ASP

Following up from my last question does anyone know how I can use a dictionary object in application scope in Classic ASP? You cannot use Scripting.Dictionary - if you try you will see something similar to the following: Application object error 'ASP 0197 : 80004005' Disallowed object use /xxx.asp, line 2. Cannot add object with apartme...