3 years ago today at the Ibero-American Summit, the Spanish king told the Venezuelan president to shut up. Ok, this takes some explaining.
Of course, it's almost a diplomatic incident when one head of state asks another, in front of cameras and everything, to shut up. Even if the one getting rebuked is acting like a spoiled brat.
As a phrase, "¿Por qué no te callas?" gained a bit of a following.
Here's a video of the event itself. Here's BBC News' take on it. And here's Know Your Meme's.
Today I meant to dig into the book and give it a good read-through, taking notes. I had it open in one of my browsers, and everything. Everything was just right. Conditions were perfect.
But then I managed to distract myself. patrickas++ showed up with an enthralling piece of SIC that he had hand-translated from a short piece of Perl 6 I had mentioned the other week. The Perl 6 is an example of closures, something that Yapsi doesn't implement fully yet.
We both tried running the SIC code (bypassing the compiler). It worked! I guess this surprised us both. That means Yapsi has the requisite support for basic closures, it's just that the compiler can't generate the SIC that the runtime already runs fine.
So why not just add the functionality to the compiler? Ah, but there's the rub. And that's where the rest of my time tonight went.
Yapsi has gone through one rewrite already. The first version of the compiler used multimethod dispatch to traverse the parse tree top-down and generate the SIC. Result: lots of small methods, all unaware of each other.
The rewrite went in the other direction: it separates the traversal logic into subs (
traverse-bottom-up), and then does all the specific SIC generation in callbacks to those subs. Result: one big callback with a long
if ... elsif ... else comb.
The new code looks scarier and messier than the old code, but it's also more expressive and, in a way, more self-aware. It brought Yapsi further than the old code would. That said, I don't much like the way it looks, and I hope that the compactness and obscurity it currently embodies is a passing phase.
Anyway — and this is why it's not trivial to add closures — there are recursive traversal calls inside the big callback, and those calls carry a
@skip argument, telling the traversal logic which nodes to ignore. Among those nodes are
block nodes (probably because nested blocks would otherwise end up in each other's generated code). But this blanket ignoring is unfortunate when we start wanting to pay attention to closures in the code.
...something like that. It's not all clear to me yet. I'm hoping that by cramming all of the gory details into my head and then going to sleep, I might wake up tomorrow with a nice solution in my head. Preferably neatly indented.