2 ms·
He's doing this only because Racket has the unusual feature of supporting images as "self-eval" values in the source code. In other languages, all you'd want i
by neilv 2y ago
He's doing this only because Racket has the unusual feature of supporting images as "self-eval" values in the source code.
In other languages, all you'd want is the byte string (maybe BASE64-encoded, maybe with byte escape sequences), and you wouldn't need a fancy reader extension: just put a byte string literal.
A variation on the byte string literal you might see is when people create a minilanguage out of strings. For example, if you want to represent a 2x pixel map image with a fairly small color map... you might just have a string literal of ASCII characters for each row, where each ASCII character maps to an RGB color (or transparent) that you specify, with a simple function to translate it to binary. Then it looks like ASCII art in your source code.
Vector images, OTOH, are more likely to have a textual language already (e.g., SVG), so of course you can just embed that as strings in your source file.