Moderators: phlip, Moderators General, Prelates
'; DROP DATABASE;-- wrote:Are there any languages with self-modification support?
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
>>> import threading
>>> import time
>>> class Foo(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.running = True
def run(self):
while self.running:
print getString()
time.sleep(4)
>>> f = Foo()
>>> getString = lambda:"Hello world!"
>>> f.start()
Hello world!
>>>
Hello world!
Hello world!
getString = lambda:"Goodbye cruel world!"
>>> Goodbye cruel world!
Goodbye cruel world!
f.running = False
>>> Berengal wrote:Since it's interpreted dynamically, essentially every session starts blank and modifies its runtime libraries through code, adding new functions and classes as it goes along.
Rysto wrote:I was under the impression that Lisp macros allow you to change the semantics of the syntax, not modify the code itself.
(defmacro triple (x)
'(+ ~x ~x ~x))
(triple 4)
; evaluates to:
(+ 4 4 4)
; but you can pass it code, and it does a similar thing so say you did...
(triple (Foo 2))
; evaluates to
(+ (Foo 2) (Foo 2) (Foo 2))
LDJosh wrote:OK. Looks like this board needs a fleeting thoughts thread. - Hammer
While testing some session data handlers, I passed an unset variable to php with the date/time format set. instead of an error, php gives me the 'beginning' of time. so according to php, time began on:
1969 12 31 19:00:00
december 31st, 1969 at 7pm sharp huh?
well let’s see when it will end. Launch outlook, go to tasks. enter a task (like live forever). in the due date, put “forever”.
Seems like time will end on:
Tue 8/31/4500
neat stuff, huh?
This is what I did at work today.
Rysto wrote:I was under the impression that Lisp macros allow you to change the semantics of the syntax, not modify the code itself.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
def getNext():
global getNext
i = 1
s = "def getNext2():global getNext; i = %d; s = %s; s2 = %s; s = s %s; exec s; getNext = getNext2; return i"
s2 = "% (i+1, repr(s), repr(s2), s2)"
s = s % (i+1, repr(s), repr(s2), s2)
exec s
getNext = getNext2
return i
>>> getNext()
1
>>> getNext()
2
>>> getNext()
3btilly wrote:There is a Perl module which lets you write your programs in Latin.
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.
wing wrote:btilly wrote:There is a Perl module which lets you write your programs in Latin.
That sounds utterly useless.
wing wrote:btilly wrote:There is a Perl module which lets you write your programs in Latin.
That sounds utterly useless.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
rrwoods wrote:I'm not too familiar with it, but I think Lisp has pretty heavy self-modification support.
(do
((var init-val update-val)
--repeat for more vars)
((end-test) return-val)
--code here--)
tehmikey wrote:FT: I wish I would have implemented a random sort on small sets of data when I was first learning to program. Many highschool teachers and professors look at the output before the code. The VASTLY varying efficiencies would prove frustrating to all testers.
Berengal wrote:tehmikey wrote:FT: I wish I would have implemented a random sort on small sets of data when I was first learning to program. Many highschool teachers and professors look at the output before the code. The VASTLY varying efficiencies would prove frustrating to all testers.
Oh, indeed. If you're shuffling the whole list, not just swapping two items, between sorted checks, bogosort is O(n!) on average. 7! = 5040. 8! = 40320. 9! = 362880.
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.
wing wrote:Berengal wrote:tehmikey wrote:FT: I wish I would have implemented a random sort on small sets of data when I was first learning to program. Many highschool teachers and professors look at the output before the code. The VASTLY varying efficiencies would prove frustrating to all testers.
Oh, indeed. If you're shuffling the whole list, not just swapping two items, between sorted checks, bogosort is O(n!) on average. 7! = 5040. 8! = 40320. 9! = 362880.
But *QUANTUM* bogosort is O(1) - which is WAY superior to everything else.
[Quantum bogosort is bogosort whewre you randomize once, and then check all possible realities to see which one contains the sorted list, and discard the rest]
A tutorial I've been reading wrote:DirectX only draws triangles that are facing the camera. DirectX defines that triangles facing the camera should be drawn clockwise relative to the camera. If you position the camera on the negative z-axis, the triangle will be defined counter-clockwise relative to the camera, and thus will not be drawn! One way to remove this problem is simply redefining the vertices clockwise (this time clockwise relative to our camera on the negative part of the Z axis)
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.
function f() {
alert( 'sheep function says baaa' );
}
function mutate(x) {
eval('x = '+
(x+'')
.replace(/sheep/g, 'zergling')
.replace(/baaa/g, 'khkhkh')
.replace(/alert/g, 'document.body.innerHTML = '));
return x;
}
f = mutate(f);
f();Dropzone wrote:All hope abandon, ye who enter here. This has to be the most overcomplicated and underdocumented piece of Java API I've ever seen...
Dropzone wrote:All hope abandon, ye who enter here. This has to be the most overcomplicated and underdocumented piece of Java API I've ever seen...
Marz wrote:Befunge is an esoteric language allowing self-modifying code.
All code exists in Fungespace, from which you may get, put, and interpret.
But it's more for fun than actual programming. It was interesting to write an Interpreter for, though.
Berengal wrote:Would you really need an AI though? Isn't that game small enough to brute-force a game-tree?
Of course, writing an AI can be fun too.
It Should Be Real wrote:Fuck the wizard.
We're doing this manually.
Ptolom wrote:why is it so goddamn hard to write a simple tile based game engine? It looked so simple, just draw the tiles on a grid and then feed back some data when they're walked on. Now I'm grappling with a program to read through huge text files full of cryptic lists of letters. Why is it never simple
Meaux_Pas wrote:I don't even know who the fuck this guy is
Ptolom wrote:why is it so goddamn hard to write a simple tile based game engine? It looked so simple, just draw the tiles on a grid and then feed back some data when they're walked on. Now I'm grappling with a program to read through huge text files full of cryptic lists of letters. Why is it never simple
'; DROP DATABASE;-- wrote:Interesting/terrifying idea: self-modifying C. A statement that says "change this other statement to this". Something like:
- Code: Select all
for(int i=0; i<5; i++)
{
fooequalsone:
foo = 1;
if(i > bar) break;
change fooequalsone foo = 0;
}
void foo() {
for(static int i = 0; i < 5; i++) printf("%d", i);
}
int main() {
for(;;) foo();
return 0;
}
Users browsing this forum: Fekeenuisance, Slageammalymn and 12 guests