Hacker News new | past | comments | ask | show | jobs | submit login

And this thread is why types help :)



Actually, if I had compiled the code produced by macroexpanding the macro, I would have gotten a warning:

  (compile nil '(lambda (x) (double x)))
  ;Compiler warnings :
  ;   In an anonymous lambda form: Undeclared free variable TEMP
  ;   In an anonymous lambda form: Unused lexical variable #:G520
Unfortunately, HN doesn't compile code you add in the comments...

Note, this is a warning and not an error because of CL's semantics, as the following is a valid program:

  (let ((temp 100))
    (double 10))
  ;returns 200
If you really wanted this effect though, normally you would have to declare that `temp` is a special variable:

  (declaim (special temp))
  (compile 'nil (lambda (x) (double x))
  ;Compiler warnings :
  ;   In an anonymous lambda form: Unused lexical variable #:G524




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: