Slashdash

Written on 2023-02-20

A year or so ago, I stumbled upon a website for yet another document language similar to YAML, JSON or XML; it was called KDL. I don't know what became of it, but it had one little feature that stood out: something they called "slashdash comments": /-. You can use it to mark code as comments, but it is scope aware.

For example, you can use it to comment out individual keywords and statements like final or implements X:

/-final class Foo /-implements Bar

But you could also use the /-- variant to comment out a whole section based on its scope:

/--public function fromInterface(int $i): int {
    return $i + 1;
}

It's just a small thing, but when I saw it, it immediately clicked. Especially in a language like PHP where "dump and die debugging" is the de-facto standard, it would be nice to have a slightly shorter and more convenient way to comment out code.

/-final class Foo /-implements Bar
{
    public /-readonly string $prop;
    
    /--public function fromInterface(int $i): int {
        return $i + 1;
    }
}
Check out my latest video: DX matters

Things I wish I knew when I started programming

Things I wish I knew when I started programming cover image

This is my newest book aimed at programmers of any skill level. This book isn't about patterns, principles, or best practices; there's actually barely any code in it. It's about the many things I've learned along the way being a professional programmer, and about the many, many mistakes I made along that way as well. It's what I wish someone would have told me years ago, and I hope it might inspire you.

Read more

Comments

Loading…
No comments yet, be the first!
Noticed a tpyo? You can submit a PR to fix it.
HomeRSSNewsletterDiscord© 2025 stitcher.io