(load "../common") (defun-match pico-style-expand-hook ((@(as form (@obj . @rest)) @nil nil) (let ((*expand-hook* nil)) (if (constantp obj) ^(quote ,form) form))) ((@form @nil @nil) form)) (defmacro pico-style (:env env . body) (let ((*expand-hook* [expand-hook-combine pico-style-expand-hook *expand-hook*])) (expand ^(progn ,*body) env))) (mtest (pico-style (1 2 3)) (1 2 3) (pico-style (let ((a 0)) (cons a (1 2 3)))) (0 1 2 3)) (defun-match infix-expand-hook ((@(as form (@x @y . @rest)) @nil nil) (if (fboundp y) ^(,y ,x ,*rest) form)) ((@form @nil @nil) form)) (defmacro ifx (:env env . body) (let ((*expand-hook* [expand-hook-combine infix-expand-hook *expand-hook*])) (expand ^(progn ,*body) env))) (test (ifx (let ((a 1) (b 2) (c 3)) (- ((a + b) * 3)))) -9) (test (ifx (pico-style ((1) cons (2)))) ((1) . (2))) (test (pico-style (ifx ((1) cons (2)))) ((1) . (2)))