redefine

Php redefine Class Methods OR Class

Is there any way to redefine a class or some of it's methods without using typical inheritance ex: class third_party_library { function buggy_function() { return 'bad result'; } function other_functions(){ return 'blah'; } } what can I do to replace the buggy_function? Obviously this is what i would lik...

How to implement dynamic arrays in Delphi

I originally had an array[1..1000] that was defined as a global variable. But now I need that to be n, not 1000 and I don't find out n until later. I know what n is before I fill the array up but I need it to be global therefore need a way to define the size of a global array at run time. Context is filling an array with a linear transf...

How do I redefine built in Perl functions?

I want to do two things: In production code, I want to redefine the open command to enable me to add automagic file logging. I work on data processing applications/flows and as part of that, it's important for the user to know exactly what files are being processed. If they are using an old version of a file, one way for them to find ou...

How can I redefine 'open' properly in Perl?

Some time ago, I ask a question: How do I redefine built in Perl functions? And the answers have served me well. I have a package that overrides Perl's 'open' function enabling me to log file access. Now I've come to a case that breaks the functionality of the original code. use strict; use warnings; use Data::Dumper; sub myopen (*;@...

Can I redefine a c++ macro for a few includes and then define it back?

I am using both the JUCE Library and a number of Boost headers in my code. Juce defines "T" as a macro (groan), and Boost often uses "T" in it's template definitions. The result is that if you somehow include the JUCE headers before the Boost headers the preposser expands the JUCE macro in the Boost code, and then the compiler gets hop...

XSD: How to redefine the data type of a simpleType eg. from xs:string to xs:integer

I am trying to extend and tailor an external xsd schema (of the fixml standard). I need to change the data type of some of the elements, without touching the original schema, but by redefining it; but have been finding it exceedingly cumbersome. What exists: fields-base.xsd <xs:simpleType name="LastUpdateTime_t"> <xs:restr...

Flex - How can I define a function in one component from another?

I'm a complete Flex/Flash noob, running Adobe Flash Builder 4 Beta 2. I have a main component that needs to be able to call several popups, each mostly the same except for one function and a few labels. Obviously, I'd prefer to be able to define this function and change those labels when calling the popup instead of having tons of .mxm...

Python __setattr__ and __getattr__ for global scope?

Suppose I need to create my own small DSL that would use Python to describe a certain data structure. E.g. I'd like to be able to write something like f(x) = some_stuff(a,b,c) and have Python, instead of complaining about undeclared identifiers or attempting to invoke the function some_stuff, convert it to a literal expression for my ...

redefine __and__ operator

Why I can't redefine the __and__ operator? class Cut(object): def __init__(self, cut): self.cut = cut def __and__(self, other): return Cut("(" + self.cut + ") && (" + other.cut + ")") a = Cut("a>0") b = Cut("b>0") c = a and b print c.cut() I want (a>0) && (b>0), but I got b, that the usual behaviour of ...

How can I change the value or a static char* from a function? C++

I am trying to change the value of a "static char *" I define at startup, I do it from inside a function, and when this function returns the var I am trying to re-set the value doesn't retain it. Example: static char *X = "test_1"; void testFunc() { char buf[256]; // fill buf with stuff... X = buf; } How can I achieve th...

How to redefine a Ruby constant without warning?

I'm running some ruby code which evals a .rb file everytime its date changes. In the file, I happen to have constant definitions, like Tau = 2 * Pi and of course they make the interpreter display the unwanted "already initialized constant" warning every time. So, I'd like to have the following functions: def_if_not_defined(:Tau, 2 * ...

timed display of div....

all i need is some client side code jQuery or JS that will alter the divs style after X seconds like visibility : hidden; OR max-height : 50px; or switch the class \ id of the DIV ( preferred ) ...

Redefine / resize C array in Objective C?

I have a C array in Objective C defined as follows: id keysArray; Then in an if block, i would like to redefine the array based on a condition: if (somethingIsTrue){ id keysArray[4][3]; } else { id keysArray[6][1]; } Then outside of the if block, when i access the array, i get errors saying the keysArray does not exist. Th...

Faster to reuse a variable defined in a common scope or redefine it in each inner scope?

C++ specifically, if it matters, but I imagine the answer lies in assembly code somehow. If we have multiple blocks in a common scope (say, a function) which each use a variable of the same type, is it faster to define the variable in the common scope and reinitialise it in each block, or redefine and initialise it in each of the blocks...