| I've always been curious about obfuscated code. Both the visual aspect of code that looks like cartoon characters swearing, and the logical aspect of understanding something that bizarre, fascinate me. Perl is a great language for writing obfuscated code. All those strange symbols, and default variables, and odd language "features" hardly anyone knows about, make it an easy medium for writing obfuscated code. I would think that Lisp, while not having such a diverse syntax, would also make a good language for writing obfuscated code. Macros, continuations, and the mini-languages like format and loop make code confusing enough for beginners that I would think someone actually trying to obfuscate code could build something truly impressive with them. But I don't know of any examples of obfuscated Lisp out in the wild. So here is my first attempt at writing some obfuscated Arc. I figure that to achieve maximum confusion, I should take advantage of macros and continuations, possibly combining the two. One idea in particular that has intrigued me is calling continuations back to macro expansion time. I had doubts that it would actually work, but I tried it and it did... I'm not completely sure how to take advantage of that, but one idea that I've had is to redefine a function every time it gets called. Here is the code: (mac mdef (name args . body)
(let cc nil
(let rc (ccc (fn (c) (= cc c) nil))
(w/uniq (mc fc return)
`(with (,mc ,cc ,fc ,rc)
(def ,name ,args
(let ,return (do ,@body)
(ccc (fn (c) (,mc (fn () (c ,return)))))))
(if ,fc (,fc)))))))
(let n 0
(mac n++ ()
(++ n)))
(mdef mutate ()
(prn (n++)))
(mutate)
(mutate)
(mutate)
Any suggestions on either refactoring or further obfuscating the code would be appreciated. |