Algebraic Data Types 2019-10-05
It took very little time for me to give the red-black tree draft some almost-decent implementations of various methods, so that's set to go soon. Looking at it inspired me to take care of an old PR I'd forgotten about, and to open a new one for one of the features I'd concluded would be nice-to-have.
I quickly realized, however, that I'd been glossing over a bunch of details.
Basically, one of the current warts with the match-based function definitions is that it's not currently possible to define the matches inside the class definition. It would be nice if there were a way to specify a placeholder that could get processed at some point after the main body of the __init_subclass__ method, so that the placeholder effectively gets replaced with the class that was just set up.
Now, because the stack iteration Just Works™, I'd forgotten about the whole "arbitrary nesting" aspect to structure definitions. Thinking about it more, I almost feel like maybe the correct solution is to just pass a callback that takes the class as a value. Then, the post-process would just be "if there's a callback, insert it but defer checking, and pass the class to it when ready."
This seems like a solid approach to take, tomorrow, when I'm well-rested.
(In case I forget, the Property setter structure should wrap the overall structure in a callback if either argument is a callback. And I guess the Function should wrap and defer if any argument is a callback.)
Anyway, I'm tired, once again. Funny how that works.
Good night.