> Oops! I'm already working full speed on this in a separate (local) Here's me telling a bit more, to compensate. :)
> branch. Sorry for duplicating work by not telling. :/
I had an interesting experience separating out the markup parsing code
yesterday. Interesting to me, anyway, at my current (early) stage of
the learning curve towards becoming a real programmer.
It occurred when I wanted to move out format_html from Wiki.pm into
Wiki/Markup/Minimal.pm -- suddenly the method make_link($title), which
produces strings of the form '<a href="...">$title</a>' as part of the
eventual output, was not visible anymore, as it was still in Wiki.pm.
Big deal, so move that as well, right? Ah, but make_link actually does
different things depending on whether the page exists or not. To do
this, it calls methods on $.storage, an attribute of the Wiki class.
So make_link should remain in the Wiki class for this reason -- and
for other reasons, such as it being used in other parts of the wiki
except for the formatter.
Ok, so I wanted to move the make_link method, except I couldn't. To
me, this seemed like a good time to perform what some people call
"Dependency Injection", and which Wikipedia defines as "supplying an
external dependency to a software component". That was exactly what I
wanted to do. Preferably just send the method make_link along as a
parameter to the formatter somehow.
However... I never figured out how to do this. I don't know yet if I'm
missing something, if Rakudo isn't capable of it yet, or if I'm simply
trying to do the impossible. Some of my bug reports today have been
The basic problem is the following: what I want isn't just to send in
the method make_link as a parameter, but to send it in so that it is
then called as a sub, not as a method. I think I want something like
.assuming(self=>self). If anyone has any idea how to emulate this
today in Rakudo, let me know.
What I'm doing right now instead is keeping a $.wiki attribute in the
formatter, and having the formatter call make_link that way. Less than