Skip to content

Functional blocks#165

Merged
Bjvanminnen merged 3 commits into
stagingfrom
functionalBlocks
Oct 13, 2014
Merged

Functional blocks#165
Bjvanminnen merged 3 commits into
stagingfrom
functionalBlocks

Conversation

@Bjvanminnen

Copy link
Copy Markdown
Contributor

Most of this diff is moving stuff around and/or renaming things in a way that makes them more clear to me.
image

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.

Comment thread blockly-core/core/connection.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment suggests that given the blocks
(and A B), (not _)
if the "not" block is dragged onto the location of the "A" block, then you'd end up with:
(and (not A) B)
i.e. because the "not" operator has only one connection point that will accept the orphaned block. is that correct? FWIW this appears to be how it works with logical operators today:
screen shot 2014-10-13 at 2 06 41 pm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized I commented on the comment that you removed. It would be helpful to explain what is being done to the orphan here besides "handling" it -- I'm curious if the old explanation is actually still accurate or not as it seems like it describes the behavior I would expect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this change does actually break the scenario you describe. I hadn't considered inputs that look like these. I'll look to add back that logic, and probably also expand on this comment.

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

FYI, adding back the singleConnection_ logic. I think the new diff might also make it more clear that handleOprhan_ is mostly extracting some of the logic that is in connect (and then adding some handling for functional_input/output that didnt exist before).

@davidsbailey

Copy link
Copy Markdown
Member

LGTM

Bjvanminnen added a commit that referenced this pull request Oct 13, 2014
@Bjvanminnen Bjvanminnen merged commit ac83da2 into staging Oct 13, 2014
@Bjvanminnen Bjvanminnen deleted the functionalBlocks branch October 13, 2014 21:47
@davidsbailey

Copy link
Copy Markdown
Member

The bump behavior I'm seeing at staging.learn.code.org/2014/12 is a little wonky. Starting with (+ 0 _)
screen shot 2014-10-13 at 2 54 39 pm
The first time I drag in the "-" block to replace the "0", the "-" block gets bumped:
screen shot 2014-10-13 at 2 54 56 pm
The second time I drag the same "-" block to replace the "0", the "0" gets disconnected but not relocated:
screen shot 2014-10-13 at 2 55 05 pm

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

That's the bug I'm fixing. My changes dont appear to be on staging yet.

deploy-code-org added a commit that referenced this pull request Oct 13, 2014
commit ac83da2
Merge: e91532b 773fe0f
Author: Bjvanminnen <Bjvanminnen@gmail.com>
Date:   Mon Oct 13 14:47:02 2014 -0700

    Merge pull request #165 from code-dot-org/functionalBlocks

    Functional blocks

commit 773fe0f
Author: Brent Van Minnen <bjvanminnen@gmail.com>
Date:   Mon Oct 13 14:37:03 2014 -0700

    add back singleConnection_ logic

commit 62fc7ff
Author: Brent Van Minnen <bjvanminnen@gmail.com>
Date:   Fri Oct 10 15:39:49 2014 -0700

    [Finishes #80230310] replacing functional blocks

commit edd1d1d
Author: Brent Van Minnen <bjvanminnen@gmail.com>
Date:   Fri Oct 10 15:30:50 2014 -0700

    cleanup connection
@davidsbailey

Copy link
Copy Markdown
Member

Nice! However, now the "0" gets bumped to almost where it would appear as a parameter of the "-" block. Perhaps worth tweaking the bump constants to make it not land so close to the child block's inputs?
screen shot 2014-10-13 at 3 47 44 pm

@Bjvanminnen

Copy link
Copy Markdown
Contributor Author

Good catch. I'll look into it.

On Mon, Oct 13, 2014 at 3:51 PM, davidsbailey notifications@github.com
wrote:

Nice! However, now the "0" gets bumped to almost where it would appear as
a parameter of the "-" block. Perhaps worth tweaking the bump constants to
make it not land so close to the child block's inputs?
[image: screen shot 2014-10-13 at 3 47 44 pm]
https://cloud.githubusercontent.com/assets/8001765/4621432/28478e5c-532b-11e4-8a6c-60850cbfe7eb.png


Reply to this email directly or view it on GitHub
#165 (comment)
.

stephenliang pushed a commit that referenced this pull request May 7, 2026
Reduce the variety of sea creatures for the bias demo and reduce the …
sanchitmalhotra126 pushed a commit that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants