The old way to handle this situation was to have code that looked like this, as a top-level form in the
"prettyprint" vocab [But this is problematic. What if locals is loaded first, and then prettyprint? Well, this actually happened, due to a change in some other code. Then locals don't prettyprint correctly! You could fix this by adding top-level statements in both vocabs, as mirrors and specialized arrays did, but then this single joint dependency is duplicated in two places. Maintenance is more difficult than it should be.
To fix this problem, I added a new word,
require-when. The code above, as a top-level form in the locals vocab, would be replaced with
"prettyprint" "locals.prettyprint" require-whenThe logic is: if the
prettyprintvocab is already loaded, then
locals.prettyprintwill be loaded. Otherwise, the dependency is registered with the module system, so if
prettyprintis loaded later by something else, then
locals.prettyprintwill be as well.
I'm pretty satisfied with this solution to a somewhat long-standing problem in Factor. I wonder how other module systems solve the same problem. I have this implemented in a branch in my repository and it should be incorporated into mainline Factor soon.