Month: February 2011

  • I Stitched a Sequin onto Elvis’ Coat…

    Well, i did the equivalent thing in the C++ world. Back in 1986 and 1987 I worked in the C++ group at Bell Labs. I was trying to debug my program, but could not understand what I was seeing from the linker–mangled symbol names generated by cfront. The documentation I was reading said I could use the demangler to figure out what the output meant, but I could not find it. In frustration I sent out an email to the group and got a message back from Bjarne Stroustrup saying something like, “It hasn’t been written yet, would you like to write it?”

    The program I created was called c++filt. The way it worked was to read standard input and try to demangle every c identifier it found. This meant we could fix the output from the linker without actually hacking it in any way. It seems that there is still a program floating around called c++filt and it works mostly the same way. I was never able to prove that I did this until recently, when a co-worker, Bryce Leblach, found a reference to me on page 197 of the AT&T documentation from cfront. Okay, so I didn’t invent C++ or any important language feature, but I did make a tiny contribution to the history of the language, one little glittering sequin on the dazzling C++ coat.

  • Geekiness

    Java is a great language, but it’s missing a feature present in its cousin languages, C++ and C. The feature is the builtin macros __FILE__ and __LINE__. These are often quite useful for debugging, etc. Well, even though Java doesn’t have them as builins, you can still make your own.

    public class MacroHack {
       public static String __FILE__() {
          return new Throwable().getStackTrace()[1].getFileName();
       }
       public static int __LINE__() {
          return new Throwable().getStackTrace()[1].getLineNumber();
       }
    }