Scratch-vm: Implement custom reporters

Created on 13 Jun 2016  ·  11Comments  ·  Source: LLK/scratch-vm

We can create a couple of stub blocks in scratch-blocks and start working on this right away, I think.

feature needs-triage request

Most helpful comment

After #280 I think we have a feature complete implementation of Scratch 2.0 custom blocks. Will be looking at the custom reporters issue sometime in the future.

All 11 comments

Title is slightly confusing.. @tjvr noted this: https://scratch.mit.edu/discuss/post/2044070/

You realise that could be parsed as “Implement ((custom blocks) and (reporters))”, right? :P

Sorry - I definitely don't mean for this to be a certain confirmation. We have a lot of work to do to determine if it will be included in Scratch 3.0.

But, we want to get started playing with the idea in scratch-vm to make sure we at least have the right code structure in its early stages to support things for this (I did mean "custom reporters").

I appreciate the excitement though :)

A couple of notes about implementation of procedures in 2.0:

Behavior is to yield if a call is detected to be recursive:
https://github.com/LLK/scratch-flash/blob/9c0728bfbe2f2ed1cff1c9f3af8d2a55552b99a5/src/interpreter/Interpreter.as#L662

Detecting if a call is recursive seems to do a 5-layer thread stack search: https://github.com/LLK/scratch-flash/blob/5cff62b909856b7d7b3d116a5dcc2b4f03de8482/src/interpreter/Thread.as#L98

To me this looks like it can cause weird behavior, e.g.: https://scratch.mit.edu/projects/119356687/

Seems preferable to do an N-layer stack search (with whatever fast implementation) unless there was some reason for the 5-limit.

Procedures affect the "stop this script" block, which calls this: https://github.com/LLK/scratch-flash/blob/9c0728bfbe2f2ed1cff1c9f3af8d2a55552b99a5/src/interpreter/Interpreter.as#L672

The other interesting feature is the "warp thread", which:

  • is turned on by setting the procedure as "run without screen refresh"
  • prevents all enclosed blocks from yielding
  • has an extended timer (warpMSecs)

Params are dealt with separately from general Scratch variables (primVarGet vs. primGetParam). This of course makes sense - the values for the params come from activeThread.args which is basically kept in a stack.

In Scratch 2, arguments aren't separate for each thread, afaik there's one copy of each argument in memory no matter how many levels of recursion are happening. Would it be possible to fix this in Scratch 3?

Edit: it actually looks like this issue was resolved. Never mind!

I made a version of custom reporters that works using stackFrame but it just freezes the block see my branch 'patch-15'

After #280 I think we have a feature complete implementation of Scratch 2.0 custom blocks. Will be looking at the custom reporters issue sometime in the future.

Are you guys talking with Jens about this? We've already been through a lot of the implementation issues about custom reporters and he probably would have useful insights for you.

@brianharvey It would be great to talk to him as soon as we're ready to implement! I know there are many great ideas in the Snap code. Thanks for mentioning that.

https://github.com/LLK/scratch-blocks/issues/904 This is the easiest way to add custom block(procedure) I think.

Would this be anything like what you are thinking?
scratchblocks

If they're called "reporters," the return block should be called "report"! :) But yeah, that's great! Now on to first class lists...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rasmushaglund picture rasmushaglund  ·  4Comments

CatsAreFluffy picture CatsAreFluffy  ·  6Comments

apple502j picture apple502j  ·  6Comments

ericrosenbaum picture ericrosenbaum  ·  3Comments

Micircle picture Micircle  ·  5Comments