Snap
Snap copied to clipboard
How to define a block programmatically?
I'm very proud of my demo using split and join of blocks to partial evaluate.
Given a normal custom block for the intersection of two lists one can ask it to create a script that tests if an intersection is empty.
The idea is that is intersection of ... and ... empty?
has no script but this program creates one from is (intersection of ... and ...) empty?
So it computes the script but how can the script be given the scriptless intersection of ... and ... empty?
block?
Hi Ken, this is cool, yay!
You should be able to simple call
the resulting ring. You should also be able to assign it to a variable and then call
that variable with two inputs.
This is as far as the current implementation is designed to go. Programmatic definition of full custom blocks (including their shape) will be the next step, of course.
Please let me know if calling that ring doesn't work for you. That part was actually not trivial to write....
Using call is particularly awkward since the script is recursive. The recursive call would need to call a global variable.
Is there anyway to get the computed script to be copied to the clipboard so the blocks can be pasted into the definition of the new block?
Ken, you could use a Y-Combinator, couldn't you? @WarpedWartWars - I don't want to turn the Github repo into another forum, please.
I really want to generated script to be easily readable - see image above. But I have no immediate plans to turn this project into a useful tool so I can wait until version 8.
I guess feature requests straddle Github repos and the Snap! Forum. Is there a preferred place for them?
Feature requests are fine anywhere, and this is a great place to discuss your ideas and suggestions, Ken. The reason I'm a little bit reluctant to invite / incite forum kids to this repo is that I don't want to end up moderating their social media issues with each other over here :-)