With Continuation Vs Normal Functions

They still look like the same to me even after reading the manual. Could you anyone please tell me the difference.

With cont gives an input to the inner proc @r4356th

Thank you but could you please show me an example?

It's not that the procedure is different; it's that its input is different. The procedure is called with the future of the process in which it is called as an input. That's a pretty magical idea; we take everything that's going to happen after this procedure finishes, sort of wrap it up in a box, and present it to the procedure itself. There are two kinds of things that the procedure can do with its continuation. One, it can invoke the continuation itself to break out of its own code; that's how CATCH and THROW work. Two, it can put the continuation in an external data structure, a global variable or a list, and then any process can revive this process, even after the procedure has returned and then entire script is done. That's how you build a multithreaded computation, for example. Those two examples are worked out in the manual; you should read them and then ask a more specific question if there's something you don't understand.

In the original post, I have said,

I am very confused with this part.

I am confused with this part, too.
Maybe I need a different example.

Sorry, I should have made it clear that I did remember you saying you'd read the manual, but I was suggesting rereading those examples in light of this discussion.

Hmm, maybe this will help... Make a global variable foo and try running these:




You should see that the procedure in the call/cc knows who's calling it.

I'll use run and run with continuation since those might be easier to understand than call with continuation.

So, with the regular run block, there are two inputs: the input for the command to run, and the input to that command.

untitled script pic
This script runs like how it looks like it would run: it has the sprite think "input" for 2 seconds, then has it say "I am the continuation of the run block." for 4 seconds.

The continuation of any block is any computational work done after it. So, the continuation of the run block is the say block, as that is what needs to be done next in the script.

The run with continuation block is the same as the run block, but the input is the continuation. Looking back at our example, here's the run with continuation variant.

untitled script pic (1)
What happens here is that the sprite will think the say block that comes afterwards. And then it will say the thing.

Thank you, @bh and @bloct.