Different but similar joke for C++: http://www.eelis.net/C++/analogliterals.xhtml
Different but similar joke for C++: http://www.eelis.net/C++/analogliterals.xhtml
Personally, the Racket idea is good except for the hassle of typing in the borders (emacs-orgmode could help with that though).
The Racket one is definitely more towards the "practical" side than the C++ one (C++ is more constrained when it comes to how it can embed DSLs) but for me it falls into a similar bucket with the label "interesting and quirky DSLs that probably aren't practically useful but make me very happy". You may disagree regarding practicality and that's okay by me but please don't take offense. :)
--
https://stackoverflow.com/questions/5508110/why-is-this-prog...
Basically, the layout is a red herring to an extent. E.g. the "\" in the shapes is only there for visuals - it's allowed because it's escaping the following linefeed, but not necessary.
If you strip out the "filler" it boils down to constructing an expression, using types and overloaded operators to represent an expression tree that is then evaluated by the C++ template processing to satisfy type constraints.
The "asserts" of sorts works by using templates to create a type that accepts only the corresponding type generated by the "literal" shapes as argument to the constructor.
It looks harder than it is because it's hard to "see" operators. Consider that e.g. "o---o" is "(o--) - o". and a rectangle boils down to "((o--) - o) | (!(!(!((o--)-o))))" or so (hope I got the parentheses right).
Sort-of. I've not bothered deciphering the exact details of how it's processed. The overall mechanism of using types and operator overloading to represent expressions is pretty well established in C++ template meta-programming, though, and is also used elsewhere. E.g. a lot of Ruby ORM query building and other DSLs is often using similar methods.