Explore + Share Site

lua for data representation - citrons.xyz

“here is a function that for any string, creates the correct multiline string to represent it:”

Jump to Highlight ↗
📖 Curated Deep Read Preview 285 words · ~2 min read

my major advocacy is that lua is a very good general purpose language. this is not an opinion shared by all. lua’s major design goal was extending and embedding into existing programs. I think the simplicity and flexibility in design persued towards the end of that goal extends to make lua a very good language in general. that said, it does its job quite well as an embedding language, and one of its more interesting use cases (and actually, one of its oldest use cases) is as a data or configuration format.

lua’s syntax provides many niceties. for instance, lua has an infinite family of multiline strings: the most basic one starts with [[ and ends with ]]. however, any amount of equal signs can be put between the two square brackets: print([======[hello, world]======]). the only way to close a [===[ is with an accompanying ]===], not with a ]] or a ]==], or a ]====].

local function stringize(str) local equal_signs = "" for e in str:gmatch("](=*)]") do if #e >= #equal_signs then equal_signs = e .. "=" end end return ("[%s[%s]%s]"):format(equal_signs, str, equal_signs) end of course, you can just use string.format with %q, but multiline strings usually provide nicer looking and more compact results. these strings are very good for representing lua code as strings in other lua code.

anyway, download this file. if you want to consume massive amounts of memory and possibly crash your computer, run it in cpython. if you want to see “hello, world” printed 5 million times, run it in lua. lua’s parser is designed to handle massive files with stride, which is fairly unique and quite necessary if lua is to be used for this purpose.

Continue reading the full piece on citrons.xyz ↗
Quick Use-Case Tags (tap to vote)
Visit Website ↗

📝 Your Private Notes & Highlights 🔒 Only visible to you

Log in or create a free account to keep private highlights and personal notes on your stored picks.

Creator Trophy & Press Kit

Featured on Storesso

Are you the creator of citrons.xyz? Share your verified feature badge on your website, or export a custom 4:5 editorial social card for Instagram and X.

Verified Website Badge
Featured on Storesso
Claim Resource →
4:5 Social Studio

Generate a 1080×1350 vertical high-res feature card tailored for social sharing.

Instagram & X Feature Card

Export a polished, high-resolution 4:5 editorial graphic displaying your verified inclusion in the Storesso Discovery Index. Perfect for launch threads, founder updates, and newsletters.

Rendered at 1080×1350px (Retina ready) · No attribution watermark required.

Curated in These Public Collections

Stay & Explore Next Continue full collection: Minimal Web & Interface Gems →
Why We Picked This · @elena_design
Exceptional visual restraint, editorial typography, and thoughtful interaction craft.
The Strength of the Record
Next in This Trail →
The Strength of the Record
The computer is a curious gadget. It is one of few human inventions which can exist purely…
Refactoring UI: Practical UI & Typography Reference for Developers
Also in Collection →
Refactoring UI: Practical UI & Typography Reference for Developers
A practical, tactical design reference that teaches developers how to design beautiful…
Discussion 0
🛡️ Safe comments: Text, Emojis & Reaction GIFs only (links & media URLs blocked)
✨ Author / Creator Quick-Reply No password required · Or Sign In