Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One example is the magical introduction of special variables. Here's "aif", implemented in PLT Scheme:

 (require (lib "defmacro.ss"))

 (define-macro (aif a b c)
   `(let ((it ,a))
      (if it ,b ,c)))

  (aif (* 10 10) (+ it 1) 'oops) ==> 101
The "aif" form makes it so you don't have to create a temporary variable name first -- the temp var is just assumed to be named "it".

If you're thinking, "whatever, I don't need that" you are wrong. :) Somehow this turns into the most wonderful little line-saver. At my last company, we used it all over the place.



Yup, I've used aif a lot, but had never got around to implementing it for myself and so hadn't made the connection with variable capture.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: