Arc Forumnew | comments | leaders | submitlogin
Obfuscated Arc
8 points by eds 6091 days ago | 2 comments
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.


4 points by bet 6091 days ago | link

You are one twisted dude. And I mean that in the most respectful way. I was all set to make some snide remark about "macex plus reformat de-obfuscates everything but variable names and silly algorithms", then I read the substance. Personally, I think you have found a counterexample to pg's "allow anything". I'm <bet@rahul.net>, but the login creation form doesn't seem to permit "@".

-----

4 points by applepie 6091 days ago | link

I think pg means to allow anything _in the language_, not in the applications

-----