PasteRack.org
Paste # 60294
2017-12-11 12:04:08

Fork as a new paste.

Paste viewed 88 times.


Embed:

expansion-order

  1. #lang racket/base
  2.  
  3. (require (for-syntax racket/base))
  4.  
  5. (define-syntax (foo stx)
  6.   (printf "expanding foo!\n")
  7.   (syntax-case stx ()
  8.     [(_ . body) #'(let () . body)]))
  9.  
  10. (define-syntax (bar stx)
  11.   (printf "expanding bar!\n")
  12.   (syntax-case stx ()
  13.     [(_ . body) #'(let () . body)]))
  14.  
  15. (define-syntax (baz stx)
  16.   (printf "expanding baz!\n")
  17.   (syntax-case stx ()
  18.     [(_ . body) #'(let () . body)]))
  19.  
  20.  
  21. (define (times-3 x)
  22.   (+ (foo (foo (foo (foo x))))
  23.      (bar (bar (bar (bar x))))
  24.      (baz (baz (baz (baz x))))))

=>

expanding foo!

expanding foo!

expanding foo!

expanding foo!

expanding bar!

expanding bar!

expanding bar!

expanding bar!

expanding baz!

expanding baz!

expanding baz!

expanding baz!