Mutual exclusion

52 views
Skip to first unread message

Max Stephen Russell

unread,
Oct 12, 2024, 1:46:23 PM10/12/24
to Blockly
What is the principle behind this rule?: "A block with a previous connector cannot have an output connector, and vice versa."

Christopher Allen

unread,
Oct 14, 2024, 9:18:30 AM10/14/24
to blo...@googlegroups.com
Hi Max,
 
What is the principle behind this rule?: "A block with a previous connector cannot have an output connector, and vice versa."

Strictly speaking the configuration of blocks and meaning of different shaped connectors is ultimately up to the developer, but Blockly and the provided library blocks make some assumptions:
  • A block with a previous connector is a statement (that can be executed). 
  • A block with an output connector is an expression (that can be evaluated to a value).
While many programming languages (particularly ones in the C family, including JavaScript) blur this distinction by having statements that just evaluate an expression and then throw the resulting value away, we think it is useful, especially for novice programmers, to clearly distinguish these two separate concepts.

It is actually possible for a block to have both, but only one or the other can be used at any given time (because each block can have only one parent block) so this will potentially be confusing for users unless done very carefully.  I have seen a demo of such "chameleon blocks", that become either statements (with next and previous but no output) or expressions (with an output but next or previous) depending on what they are attached to.  Alas I can't find a running demo but you might be interested to read some previous discussions on this forum about the idea.


Best wishes,

Christopher

Message has been deleted

Christopher Allen

unread,
Oct 28, 2024, 7:12:26 AM10/28/24
to blo...@googlegroups.com
Hi Max,

  • A "next" connection denotes where  to find the statement to be executed after the current block.
  • An "output" connection denotes that the block evaluates to a value, which can be used as the input to another block.

Christopher

Max Stephen Russell

unread,
Oct 28, 2024, 9:25:29 AM10/28/24
to Blockly
My questions at this stage are posted after I've studied a particular Blockly guide and other related docs, and playgrounds. When I finally get around to actual coding and design, these things will fall into place in my understanding. But I can't always wait for that next stage while in the midst of trying to lay a foundation.

Your explanation of the "next" connection verifies what I thought I observed in the code output of some playground testing but couldn't quite see in the guides and elsewhere.

So thank you very much, Christopher!

Steve
Max Stephen Russell 

Reply all
Reply to author
Forward
0 new messages