RETURN in Custom Block does NOT return

Issue #183 resolved
Turgut Guneysu created an issue

With a Local Var:

With Global Var:

Comments (9)

  1. Bernat Romagosa

    Hi, Turgut.

    The report block is meant to be used in reporters, not in command blocks. Command blocks perform actions, they don’t have a return value, whereas reporters return values and do not perform actions.

    I hope this answers your question 🙂

  2. Turgut Guneysu reporter

    report block is meant to be used in reporters, not in command blocks. 

    I am confused !

    I can use the RETURN block anywhere in a normal program context and it reports.

    What am I missing?

  3. Bernat Romagosa

    That’s sort of a helper. You can use the report block by itself, or in scripts, as a sort of debug output. When used inside of a function, though, the function will return that value and stop the execution there. If the function is a reporter block, MicroBlocks will know what to do with it, but if it’s a command block it will just be ignored, as command blocks aren’t supposed to return anything.

    Just FYI, the behavior is exactly the same in Snap!. Try this out:

  4. Turgut Guneysu reporter

    Thanks for the explanation.

    The notch at the bottom of the Return block threw me off, and made me think it is a freely executable block, which I as trying to use for debug info and not to return actual values. But I now do see that execution stops at the Return block as well.

    Well, Live and Learn !

  5. Bernat Romagosa

    Actually, I think you’re totally right. The return block should be final and not have a tab at the bottom. The same is true for the forever block, nothing that you attach after a forever loop will ever run, so it doesn’t make sense for the block to have that tab.

    I don’t think there’s that kind of block shape in GP, but I guess it should be pretty easy to patch that.

  6. Log in to comment