It’s David here from MIT App Inventor. I have been working on implementing let* and letrec for App Inventor and I would like some feedback from our community.
First of all, Do you think these new blocks would be appreciated?
Next, I’m having a hard time how to name the blocks. Basically, the first two are let* and the bottom two are letrec. Any great ideas how what would be the best way to name these blocks for the users?
The biggest usage would be that these blocks would allow to reference local variables defined on the same let block. So the need for nested let blocks will be unnecessary
@TimAI2's idea of allowing upward references in the local init covers your use case, and conforms with the idea in block languages of supporting dependencies by spatial reasoning.
Data flows from right to left, control flows from top to bottom with occasional branching to the right, and initialization flows from top to bottom, even within the same init block.
I guess us "old timers" are used to the behaviour of the local variable blocks as they are.Newer users will find out by trial and error that variables cannot be set and available at the top.
Given the points raised, I also am not sure we really need letrec. It's effectively syntactic sugar for the regular let block where all of the variables can first be initialized with some trivial value (false) and then within the scope of the block set the variables to the desired values. I agree with ABG that generally for beginners it's good to have the flow be treelike to make it easier to reason about whereas letrec opens up the opportunity to make graphs with cycles that are harder to reason about. I recall a thread with Lyn years ago where we explored this idea. I will try to dig it up.
Just smarten up the existing init blocks with multiple sockets, behind the scenes.
Counter-argument:
On further thought, the current limitations may be wiser, albeit not more clever.
Nested init block clusters read like topographical maps, where the density of the inclination lines (isoclines) tell you in advance that you are headed for a cliff.