the trouble with anonymous gizmos

This post considers what the gizmo-naming insights from the first three posts in this series have to say about anonymous gizmos.

The first three posts built up my concept of the gizmo: some kind of automatic behavior attached to a free-form label. Many things fit under this umbrella, but I've focused mainly on functions, CSS classes, and tagged markup (like HTML).

anonymous functions

My focus on functions took it for granted that functions have names, but many programmers use languages with anonymous functions like these:

1() => 1 + 2;
1lambda: 1 + 2;

I won't dwell on these, but I do want to answer the most obvious question:

Since I recommend including a bit of why in each function name, should we treat anonymous functions as an antipattern?

Strictly speaking, you'll answer this question upstream from my recommendations.

Because my focus is re-use, my recommendations (use new names when you call a function for new reasons) are irrelevant to anonymous functions until you decide to DRY an unnamed1 function's code. When you commit to factoring it out into a named function, weigh whether each instance has the same purpose.

That said: just factor identical anonymous functions out and name them. The name(s) will clarify whether the functions do the same thing for the same or different reasons.

anonymous... markup?

So far, this series referred to tagged/labeled markup languages like HTML, but now I'd like to turn to unlabeled markup. I imagine most readers will be familiar with Markdown--but I want to call out a few things about the following Markdown sample: 2

1- we love lists
2
3    _especially_ when they contain **3** paragraphs
4
5    > and a block quoted
6    >
7    >     code block
  1. The markup elements are unlabeled.
  2. The automatic behavior associated with these unlabeled gizmos is triggered by symbols and whitespace.

It's not present in the example itself, but I also want to note that the lack of free-form labels:

  • Leaves us no way to distinguish different reasons for using the same presentation, hampering our ability to translate into formats with distinct markup for each reason.
  • Focuses authors on presentation, making it more likely that they'll mix reasons.

Bridging anonymous functions and unlabled (~lightweight) markup makes it clear that they have more or less the same value and problems. As with anonymous functions, unlabeled markup formats prioritize authoring speed over future re-use. That'll be a good trade for many uses--but not always.

Note: This is an attack on most unlabeled lightweight markup languages (well, on using them as source languages)--but it's a narrow one. They are convenient! (I'm writing this post in Markdown!)

Much as anonymous functions are fine when you don't need labeled functions for re-use, unlabeled LWMLs such as Markdown and AsciiDoc are fine if you don't need to translate to more-functional formats. It's important to understand where our technical choices begin to creak.

Conclusion

Over the course of this series, I've tried to sketch out some big ideas about how to practice ~namescaping, but here's the pocket-reference version:

  1. Name your gizmos to reflect why you're using them.
  2. Prefer languages that make this easier.

I stumbled onto the core ideas in this series while wrestling with how to write about some tools I've been working on for documentation single-sourcing. More specifically--for generating multiple heterogeneous 3, idiomatic 4 documentation outputs from a single source corpus.

Stay tuned if you found any of this interesting. The journey has been fruitful so far, and I imagine I'll make several more posts building on these ideas in the coming months. In particular:

  • At least one post on the 8-letter S word that I've left out of this series.
  • A series on where and how separation of concerns goes awry in the HTML/CSS ecosystem, including why almost everyone gets this wrong.
  • One or more posts on how templating toolchains aren't up to the task of handling source and output formats with very different whitespace requirements.
  • A few puff pieces on fun/quirky little languages I stumbled on while looking to see if I could avoid reinventing a wheel.
  • And, finally, one or more posts on what I've made.

  1. Minor hair-splitting. Using unnamed to distinguish between functions declared with an anonymous constructor but named by saving them to a variable. â†Šī¸Ž

  2. GH renders roughly (I stripped some flarf) the following HTML:

     1<ul>
     2<li>
     3<p>we love lists</p>
     4<p><em>especially</em> when they contain <strong>3</strong> paragraphs</p>
     5<blockquote>
     6<p>and a block quoted</p>
     7<div><pre><code>code block
     8</code></pre></div>
     9</blockquote>
    10</li>
    11</ul>
    
     â†Šī¸Ž
  3. not 1-to-1 translations â†Šī¸Ž

  4. they take advantage of the target language's features â†Šī¸Ž

Discussing this elsewhere?
Enter 'link' for a markdown link
or 'tweet <message>' for a pre-populated Tweet :)
Want to subscribe? Enter 'rss' for a feed URL.
>