Open DavidGasku opened 5 years ago
For blocks that are ringified in the same place, as in your picture, I suppose it could work. But in general it's really hard to compare functions; even Scheme punts on this.
Well, then I'll use this issue as a suggestion. I think it would open many possibilities:
Some custom block could turn this:
into this:
And be able recursively to travel the program tree until the parameters:
Oh! Yes! The ability to convert back and forth between blocks and abstract syntax trees is at the very top of my list (not to be confused with Jens's list :-/ ). That's what we need to implement Scheme macros.
But it won't entirely solve the problem. The text equivalence of two blocks is both too broad and too narrow a criterion. Too broad because the same block text reified in two different contexts are not the same function: Plus3 and plus4 are derived from the same (in the eq? sense) ringed expression, but they implement different functions.
Too narrow because different texts can create the same function: F and g have different texts, but they implement the same function.
This is why Scheme just throws up its hands. It'll tell you reliably if two functions are EQ?, meaning that they're the very same memory location, but not if they're EQV?, equivalent values.
Well, I would just compare the specs. It's not necessary to go down to the semantic level.
Another user case that this feature could enable: In one of my lessons about coordinates and symetries, students have several painting primitives like
I wanted to have a C-shaped block to draw the symetric drawing, so
would also draw
Unless I'm missing something, this is not possible at the moment.
You can fake it with an ugly global variable hack. Have the LINE block set LAST ACTION to a list with the word LINE and the four coordinates. Then your X SYMMETRY block can run its input, and then review LAST ACTION to decide how to flip it. (If you want multi-command scripts flipped, make LAST ACTION a list to which LINE adds its list of coordinates.)
I agree that this is hideous. We should definitely fix it.
Shouldn't this comparison give true? I'm trying to make autocorrected lessons for my students, and I need to compare code given as a parameter, but it doesnt work.