code-dot-org/code-dot-org — pull request #165 by Bjvanminnen (2014-10-10 22:48:19+00:00)
Title: Functional blocks

Most of this diff is moving stuff around and/or renaming things in a way that makes them more clear to me.
![image](https://cloud.githubusercontent.com/assets/1767466/4599998/98114d90-50ce-11e4-8f23-98fefd154d3f.png)

The second part (commit #2) makes it so that when you try to replace the - block with the * block, it will properly move out the - block.

The reason this didn't work before is because there's some opportunity for confusion for how things are organized right now. Block connections have types (i.e. like next_statement, previous_statement, input_value, output value). These are used to ensure connections only matchup with other connections of the right type. Blocks then also have a set of connections (nextConnection, outputConnection, previousConnection) used to point at particular connections. These are also used to determine how to draw the block.

When I added the functional_input/output, I want it behaving like the existing input/output connections in some senses (i.e. inputs are drawn internal to the block, output represents the result of processing the block). However, I want it drawn more like next/previous connections. I accomplished this by having the block have a previousConnection of type FUNCTIONAL_OUTPUT, whereas before previousConnections would always be PREVIOUS_STATEMENT.

There might be opportunity to clean up some of that confusion in the future.