Anyone have any favorite/creative delimiters for HEREDOCs or other string formats that accept user-created delimiters?

I tend to default to EOF, but that character sequence isn't *that* unlikely to appear in the text.


> Anyone have any favorite/creative delimiters for HEREDOCs or other string formats that accept user-created delimiters?

I'm almost embarrassed to admit that it took seeing my own question for me to realize it, but § is a great delimiter – unlikely to occur in most strings, semantically meaningful, and easy-ish to type (via a compose key on Linux or opt-6 on mac). Plus, it's short enough to repeat if it's present in the text

I think I'm going to switch to § (maybe with a content tag: §html)


> That's not ascii-safe, though.

For most of the code I write, the ascii-safe ship has not only sailed but is well out to sea 😁


I stopped using HEREDOCS in favor of the Python Click library and the sh library.
Better for testing and CICD

@codesections I usually include the content type, similar to markdown. So your suggestion of section symbol + content type seems ideal.

As an added bonus, it's in Latin1

@codesections It took me *far* too long to realise that § was a better delimiter than ⭲; in fact, I only realised three days ago.

@codesections I think so.

The character trashes my text editor (Geany), too; if it's the first character on a line, all the leading spaces become 1-pixel wide, and it breaks the monospace. And I was going to use it as the “attribute access” character in my programming language.

It's cursed.

@wizzwizz4 @codesections Why would you want to use a character that can't easily be typed as part of the reserved set?

@brandon @codesections Because I was using most of the punctuation as punctuation. Dot was full stop, comma was comma, semicolon was semicolon. Arrows were used for function prototypes, colons were used for type designation (and ratios)…

I wanted an easy-to-type one, but I thought I'd run out. Turns out the section sign was unused, though.

@wizzwizz4 @brandon also on the "embarrassingly long to realize" score, at least *you* don't have section/§ as part of the username and icon that you use basically everywhere :D

@wizzwizz4 @codesections I take it you didn't want to use escape characters to turn those symbols into reserved-set chars? (There's gotta be a word for the type of symbol I'm calling "reserved-set characters")

@brandon @codesections No, I mean, my language's syntax *currently* looks like:

if x > 4, print(x); else, print(y).

If I try to overload . for full-stop and attribute-access, the syntax will be horribly confusing.

@wizzwizz4 @codesections Ahh, I see what you're trying to do. It's a programming language intended to have English(and other)-like sentence structure?

@brandon @codesections Not really; at the point I decided on that syntax, it was intended to allow almost one-to-one representation of most mathematical conventions. I've moved away from that a little now, though the language's syntax is still supposed to be extensible enough that that's possible.


head -c 35 /dev/urandom | base32

ASCII-safe, less likely to occur in some arbitrary text than a disc error causing an actually unique text to pop at random, and I see no reason for the delimiter to be very short (it's not like I type it manually anyway). When I need some artificial delimiter which needs to be short, I like broken bar “¦” (0xA6) since I don't think I've ever seen a “natural” use for that. (Not ASCII safe, though, but I very rarely need that these days.)

Sign in to participate in the conversation

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.