Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

breaking ocaml

The guy next to me was learning SML for his intro to programming languages class, so I tried to impress on him how awesome and fundamentally mind-altering it was. But he hadn't encountered a functional language before so he couldn't see why type inference was so neat.

chris_one pointed me at a paper that eventually led to me producing this OCaml gem:

Note that we never actually use x, and instead just assign to q. So the ensuing grinding is just a product of the type-inferencer.
let q = 
let x = 1 in
let x1 = (x, x) in 
let x2 = (x1, x1) in
let x3 = (x2, x2) in
let x4 = (x3, x3) in
let x5 = (x4, x4) in
let x6 = (x5, x5) in
let x7 = (x6, x6) in
let x8 = (x7, x7) in
let x9 = (x8, x8) in
let x10 = (x9, x9) in
let x11 = (x10, x10) in
let x12 = (x11, x11) in
let x13 = (x12, x12) in
let x14 = (x13, x13) in
let x15 = (x14, x14) in
let x16 = (x15, x15) in
let x17 = (x16, x16) in
let x18 = (x17, x17) in
let x19 = (x18, x18) in
let x20 = (x19, x19) in
x20 in
1


Reminds me a lot of that "million laughs" XML attack, where you create entities that expand recursively.
Subscribe

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments