Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scheme@(guile-user)> (sc-expand '(cond (a 1) (b 2) (c 3) (d 4)))
- $21 = (if a (quote 1) (if b (quote 2) (if c (quote 3) (if d (quote 4) (void)))))
- Okay, that’s a straightforward expansion.
- scheme@(guile-user)> (sc-expand '(case a ((50) 1) ((60 70) 2) ((80 3) (90 4))))
- $23 = ((lambda (#{ g6254}#) (if (memv #{ g6254}# (quote (50))) (quote 1) (if (memv #{ g6254}# (quote (60 70))) (quote 2) (if (memv #{ g6254}# (quote (80 3))) ((quote 90) (quote 4)) (void))))) a)
- But that isn’t very readable, is it?
- Following are what Guile’s internal macro-expander produces; it outputs the Tree-IL language rather than Scheme.
- scheme@(guile-user)> (macroexpand '(cond (a 1) (b 2) (c 3) (d 4)))
- $26 = #<tree-il (if (toplevel a) (const 1) (if (toplevel b) (const 2) (if (toplevel c) (const 3) (if (toplevel d) (const 4) (void)))))>
- (macroexpand '(case a ((50) 1) ((60 70) 2) ((80 3) (90 4))))
- $27 = #<tree-il (let (key) (key-6338) ((toplevel a)) (if (apply (@@ (guile) memv) (lexical key key-6338) (const (50))) (const 1) (if (apply (@@ (guile) memv) (lexical key key-6338) (const (60 70))) (const 2) (if (apply (@@ (guile) memv) (lexical key key-6338) (const (80 3))) (apply (const 90) (const 4)) (void)))))>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement