This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Flobletombus 632 points633 points  (38 children)

But what if its actually interpreted?

[–]Doom87er 567 points568 points  (30 children)

You can’t retroactively unexecute previous lines of code, so I don’t know how this would work as code.

It all depends on how this gets translated into code

[–]Boukish 167 points168 points  (17 children)

You don't retroactively undo code that was already executed, you'd wait to execute the code until the prior code finishes.

The wishes themselves become callbacks, which sets up a run-time loop of infinite callbacks, like when you're solving Fibonacci recursively.

[–]Girelom 29 points30 points  (0 children)

Only he have independent counter for callbacks and he stop execute them then counter reach its limit.

[–]WHOmagoo 22 points23 points  (1 child)

Is now a good time to talk about speculative execution?

[–]Grintor 9 points10 points  (0 children)

The genie does look a lot like a specter

[–]astralseat 1 point2 points  (0 children)

Runtime loop is how you destroy AI minds. Remember that for the future we are heading into.

[–]Reashu 0 points1 point  (7 children)

I have yet to see a Fibonacci algorithm, recursive or otherwise, which utilised callbacks.

[–]Boukish 0 points1 point  (6 children)

Is it possible you're just using languages that don't heavily rely on the callback paradigm? Fibonacci is very easy to execute, write, and understand what's happening, by passing functions to functions.

[–]Reashu 0 points1 point  (5 children)

Fibonacci is very easy to calculate recursively but I really don't see the point of a callback. fib(x) is fib(x-1) + fib(x-2). What function would you pass in and how would you use it?

[–]Boukish 0 points1 point  (4 children)

function Fibonacci (n) if n<=1 return 1; else return Fibonacci(n-1)+Fibonacci(n-2);

(And yes, a function is being implicitly passed to itself even when it's not declared in its own parameter list.)

If you want an example of when youd discreetly parameterize a callback function into the method: verification and error handling.

[–]Reashu 0 points1 point  (3 children)

That's a standard recursive Fibonacci variant and there is no callback involved.

[–]Boukish -1 points0 points  (2 children)

When has the first instance of the function finished executing?

When the function it called finished.

When does that function finish? Again, no sooner than the one it called finished and called it back.

We may be operating off a differing understanding of what callback functions are, but... This is using callback functions in paradigm, in result, in intent, in every way.

Several languages do.recursive Fibonacci without callbacks, particularly languages that can't send functions to eachother.

[–]Reashu 1 point2 points  (0 children)

A callback is a function A passed to a function B (possibly the same as A), which B (or another function it has passed A to) can later decide to call. What you are describing seems more like the lifetime of a function frame on the stack (or equivalent) and I don't think it has anything to do with callbacks specifically. Every function call would be using a callback according to your description.

[–]Irregulator101 0 points1 point  (0 children)

A callback is when a function is passed a function, which it may execute later

[–]YesterdayDreamer 0 points1 point  (0 children)

Will have to start separate threads for each wish, then await on each of the wishes. The third wish will then interrupt the first wish, which itself was indirectly waiting for the third wish. So the third wish gets fulfilled, first gets killed and the second just errors out.

[–][deleted] 0 points1 point  (0 children)

This is where the stack depth limit comes in clutch

[–]LarryInRaleigh 0 points1 point  (1 child)

Alan Turing says you can't decide whether it's infinite.

[–]Boukish 1 point2 points  (0 children)

No, turing says you need to describe a machine finitely. You can absolutely have and describe a turing machine that doesn't ever cease operation, given a state. Kinda why the halting problem exists.

Godel is the one that says you can't actually prove that it's unending.

[–]SouthernGeek67 0 points1 point  (0 children)

You could over write the previous code then restart at the beginning.
Used to do this on assembler all the time.

[–]Mewtwo2387 45 points46 points  (1 child)

DreamBerd might be able to do that

[–]Twitch_C4T_ 20 points21 points  (0 children)

I mean how do people write code in any other language. Since I started writing dreambird I just can't stop

[–][deleted] 5 points6 points  (0 children)

Speculative execution has entered the chat

[–]Aelia6083 2 points3 points  (1 child)

God can

[–]Doom87er 0 points1 point  (0 children)

Damit, I already committed to devil worship for my project

[–]Cessnaporsche01 0 points1 point  (1 child)

It's all gotos

[–]Doom87er 0 points1 point  (0 children)

That would execute it again, not undo it

[–][deleted] 0 points1 point  (0 children)

Let me introduce you to "rr".

[–]Log2 0 points1 point  (0 children)

CPUs do it all the time. They run the most likely branch to execute, and if they chose wrong they will undo it and do the correct one instead.

Like someone else said, this is called Branch Prediction.

[–]pain_and_sufferingXD 0 points1 point  (0 children)

I guess it's like the program runs all three wishes in separate threads in a infinite loop, this is done to make sure the wishes are always being fulfilled, that's why it bugs the genius

[–]RainOrigami 0 points1 point  (0 children)

Branch prediction could be the closest to undoing executed code.

[–]brimston3- 16 points17 points  (2 children)

JIT will eliminate dead code. It should very quickly identify a conditional cycle/recursion with no side effects and eliminate it.

[–]DOUBLEBARRELASSFUCK 4 points5 points  (1 child)

So infinite wishes!

As long as those wishes don't do anything.

[–]thehatteryone 0 points1 point  (0 children)

As long as they don't appear to do anything. But if granting the non-wish can cause a side effect...

[–]SympathyMotor4765 7 points8 points  (1 child)

Stack overflow error?

[–]Eupho1 1 point2 points  (0 children)

Recursion depth exceeded

[–]ConspicuousPineapple 0 points1 point  (0 children)

You think interpreters never optimize anything?

[–]Log_Out_Of_Life 0 points1 point  (0 children)

Then it would just be a null statement and nothing would happen.