Discussion about continuations

if i run this script,
untitled script pic (25)
the sprite will say an empty ring every loop iteration. am i using the block wrong or is this a bug?

Try this
untitled script pic

is there a way to make it also return stuff outside of the loop?

You would have to call it before (outside) the loop.

Edit: actually, you have to make the loop get the continuation, like this

untitled script pic - 2024-08-21T142119.827
untitled script pic - 2024-08-21T142200.963

By the way, this is basically just from the iteration composition library (I modified the catch block to not use the deprecated run w/ continuation block).

But why is the RUN needed? Shouldn't it work without that?

that's what i was thinking.

the continuation of a top level script is ... nothing, because when the script is done there's nothing left to do. If you quote a script using a ring, then there's something to continue.

But in the original example, we're not getting the continuation of the entire script; we're getting the continuation of the THIS CONTINUATION, which is the SAY and the remainder of the loop and the MOVE 10 STEPS.

I thought maybe the issue was that we have no good visual representation for a partially-completed REPEAT in a continuation, but that actually running the continuation would work, so I tried this:

which should actually be an infinite loop, but no, running the continuation does nothing.

Edit: Is THIS CONTINUATION actually not a full replacement for CALL/CC because THIS refers to the entire script rather than the exact place we're up to?

if you put it in a custom block, it works as you'd expect.

This is making me so mad, Brian, you've forgotten everything you taught yourself, and everything we've designed together.

runccold

has become

runccnew

because we now have actual first-class continuations, not just as a by-product for a special kind of call.

And now please think before you again blindly reinforce some forum kids' misconception.

Did I mention how mad this makes me?

Sigh.

You said:

But the example under discussion asked for a continuation partway through the top level script, like this:

define stuff script pic

The captured continuation shouldn't be "nothing"; it should be

define stuff script pic (1)

And, indeed, that is what this does:

but that's not what THIS CONTINUATION does. It makes the continuation of the entire script, not the continuation of the call to THIS CONTINUATION. So, as I said in my message that got you so angry,

So maybe next time instead of going right to getting angry, and instead of assuming I'm an idiot, maybe you should actually read my message before you answer it.

As my message made crystal clear, I know that THIS CONTINUATION was meant to replace CALL/CC. But in fact they are not interchangeable.

this is unbelievable, Brian. You simply refuse to even read, let alone remember, how your own example script behaves. I'm giving up on you. Plus, you've forgotten all about Scheme and functions and applicative order of evaluation. We've had this time and again: You mistake a function call with a function. I'm outta here and won't reply any more. This is upsetting me beyond telling.

I don't see what I'm not reading, let alone remembering. Our CALL/CC block does the right thing.

sigh. Okay, I will reply once more:

try it!

or, if you want to be more explicit and complicated:

You might've posted that in the first place instead of yelling at me, perhaps in a context such as "Yes, you're right, Brian, I thought you understood that THIS CONTINUATION isn't a direct plugin replacement for CALL/CC, but it can be used to implement it:" and then the picture.

I still don't understand what applicative order, or functions versus calls, have to do with anything.

Didn't I, though?

The whole point about a first-class continuation is, that it is - same as caller and script - an attribute of the current context, which is a function. They cannot be a property of the expression whose argument they become, and this is because of applicative order of evaluation.

No, this:

is not the same as this:

The latter specifically answers my point about THIS CONTINUATION, which reports the continuation of the entire script, not being equivalent to CALL/CC, which passes in the continuation of the CALL/CC expression itself.

In fact, the former isn't even true!
runccold
is not the same as
runccnew
since the latter provides the continuation to something different from the former.

Well let me just point out that that isn't how anyone else on Earth uses "continuation," which is in fact precisely a property of an expression.

I don't think it's fair of you to yell at me for not knowing intuitively that you've decided to use "continuation" to mean something different from what everyone else means. Only Humpty Dumpty is allowed to do that.

And we know what happened to him.

But that's so not right, you're mixing up cause and effect. In Scheme you're catching the current continuation with a call/cc expression. That expression in Snap! is a block. If we build that block ourselves we need it to access the evaluator's current context ("frame") when running its definition body, and that, my friend, is a function.

That's fine, you're talking about what you need to do to implement continuations.

But what a continuation means is "what remains to be done in the computation after this point?"

So, for example, if we have

define stuff script pic (3)

define stuff script pic (4)

what is the continuation of define stuff script pic (5)? Answer: it's
define stuff script pic (6)

Again, asking "what is the continuation of define stuff script pic (5)?" entirely fits with the meaning of the word "continuation." And that continuation includes both part of the body of the current function and part of the script that calls it. Whether the program is expressed in Scheme code, Snap! blocks, or a Turing Machine program is entirely orthogonal to the fact that after every piece of a computation, there's some more work to do, and that "more work" is what the idea of a continuation captures.

I mean, Jens, think about something as simple as CATCH and THROW. If you say


the THROW isn't asking to leave MY BLOCK; it's asking to jump to the purple command block.