The idea is to just make the dispatch list once and have it remembered. And some of them need to be accessible in more than one block. We need a package system, real soon now.
Yes, if they were accessible in more than one custom block.
One of the big disadvantages of a visual language (or at least of this visual language) is that calling a function made with lambda takes more effort than calling one made as a named block. If I say
compared to
if I make a named block. This isn't the end of the world, but it's a disincentive to putting 25 anonymous functions in 25 block variables as I would have to do in this application.
Another disincentive is that if I do it with anonymous functions I end up with one huge long block definition for SET PEN [attribute] TO [value...], which then is hard to edit because it takes forever for the block editor to load.
These are all implementation details, and we could do things differently, and we should figure out how the "differently" should work to be efficient both in computer time and in human (programmer) time. One thing I think would help a lot would be the ability to say "Make a Block" inside a block editor and have the new block be treated as lexically inside the original block, so it has access to local variables etc. The trick is to do that in a way that doesn't require opening block editors for all the internal functions when you edit the outer one.
But also a block should be able to create other blocks that are then globally available.
You know how you can make sprite-local blocks that are visible in the palette only when you're editing in that particular sprite? A package is the same idea, but not tied to a sprite; you make a bunch of blocks that are local to a package, and only the blocks making up that package can see them. (But the package will typically also export a few blocks that are globally visible, so in the color library the eight (I think) blocks that have $brush in their names would be globally visible, and the other 40 or 50 helper procedures wouldn't be.
Actually, duh, now that I'm explaining this I can see that we don't have to invent packages; we can just use (hidden) sprites. So the only thing we have to change is to let the library contain XML for sprites as well as for sets of blocks.
The idea is to just make the dispatch list once and have it remembered. And some of them need to be accessible in more than one block. We need a package system, real soon now.