I sometimes wish software compilers wrote back significant info, directly into the file.

I know some editors show all sorts of stuff on hover, or in between lines or something.

I just want comment blocks of text written by the compiler.


For example, types. Some compilers make you write out all of the types. Some (arguably better) compilers infer types, but: they often don’t write the types down for you.

If you write

function square(x) {
	return x * x

it could, for an imaginably good compiler, output something like

/** langcc-v2.2.0 at 2020-10-10 12:34:56-0400
 * square ⦂ M → M
 * where
 *   "M" Multiplicative = dom(*)
 * 0/0 tests passing
function square(x) {
	return x * x

or what have you.

The compiler would completely rewrite the /** .. **/ blocks (conceptually, at least) on each recompile.

Recompiles would be triggered by a debounced low-latency feed of saves, in watched directories et cetera.

You could, in theory, completely change what goes into these blocks. If you had some sort of plugin system, you could see people wanting (maybe not all at once):

  • git revision history (most recent commit/author, N most recent, all the way up to complete date-author-message commit listings per function)
  • test information (summary, details for fails, full details)
  • type information for arguments and returns
  • references (forward (what this calls), back (who calls this)) within a codebase
  • deprecation or style warnings
  • a place to enter doc comments by hand, of course
  • even so far as suggested refactorings

It’s more or less plaintext IDE stuff, in comment blocks.

I know this isn’t exactly a brand new idea, prior art &c &c, I just wish this were more default. REPL is great, yeah, but Save-Watch-Rebuild-Writeback has got something great about it. It’s more a reified development experience.