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

Just nitpicking. The first example that uses define-syntax-rule can also be fixed with “...”. He uses the “...” later in syntax-parse, but they are available in define-syntax-rule too. With syntax-parse is easier to construct advanced macros, but I like to use define-syntax-rule for small throwaway macros.

  #lang racket
  (define-syntax-rule (def id body ...) (define id body ...))
  (def (vector-swap! vec i j)
    (def t (vector-ref vec i))
    (vector-set! vec i (vector-ref vec j))
    (vector-set! vec j t))
  (let ([v (vector 'a 'b 'c)])
    (vector-swap! v 0 1)
    v)  ;==> (vector 'b 'a 'c)

Thanks for telling! (I've written a bit of a response here: http://artyom.me/learning-racket-2#gus_massa-from-hn .)

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