broadcast block inputs

Issue #196 resolved
Turgut Guneysu created an issue

This block permits inputs of type LIST and BOOLEAN T/F, however it does not act on them, and does not produce any error messages either. User is left with no feedback. Inputs should be restricted to strings and numbers.

Comments (2)

  1. John Maloney repo owner

    MicroBlocks is a dynamically typed language so, in general, it’s not possible to know the type of a value returned by a reporter block when the program is being constructed. One obvious example is variable blocks. The same variable could contain a number, a boolean, or a list at various times during program execution.

    One could, of course, stop with an error when trying to broadcast a list. However, error messages are can be discouraging or confusing for beginners who don’t yet have the necessary context to understand the error message. In Scratch, we chose to avoid explicit error messages, and I think that design choice for a beginner system has stood the test of time.

    A possible design choice would be to disallow dropping reporters into the “broadcast” block. But that choice eliminates a number of compelling use cases for more advanced users, such as broadcasting a string (i.e. a command) received over radio or broadcasting an integer to run one of a set of alternatives, which can be used to simulate a case/switch statement.

    Note: Although this is a hack, you can actually broadcast boolean values, but you need to use the strings “true” and “false” in the “when _ received” block:

  2. Log in to comment