diff --git a/extra/lisp/lisp-tests.factor b/extra/lisp/lisp-tests.factor index cf9811e4a5..e539221eaf 100644 --- a/extra/lisp/lisp-tests.factor +++ b/extra/lisp/lisp-tests.factor @@ -66,14 +66,6 @@ IN: lisp.test { { 1 2 { 3 { 4 } 5 } } } [ "(list 1 2 (list 3 (list 4) 5))" lisp-eval cons>seq ] unit-test - - { T{ lisp-symbol f "begin" } } [ - "(defmacro begin (&rest body) (list (cons (quote lambda) (cons (list) body))))" lisp-eval - ] unit-test - - { t } [ - T{ lisp-symbol f "begin" } lisp-macro? - ] unit-test { 5 } [ "(begin (+ 1 4))" lisp-eval @@ -84,7 +76,7 @@ IN: lisp.test ] unit-test { T{ lisp-symbol f "if" } } [ - "(defmacro if (pred tr fl) (list (list (quote cond) (list pred tr) (list (quote #t) fl))))" lisp-eval + "(defmacro if (pred tr fl) (list (quote cond) (list pred tr) (list (quote #t) fl)))" lisp-eval ] unit-test { t } [ diff --git a/extra/lisp/lisp.factor b/extra/lisp/lisp.factor index e6e3a7b13b..967c52a117 100644 --- a/extra/lisp/lisp.factor +++ b/extra/lisp/lisp.factor @@ -63,6 +63,10 @@ PRIVATE> : macro-expand ( cons -- quot ) uncons [ list>seq >quotation ] [ lookup-macro ] bi* call convert-form ; + +: convert-begin ( cons -- quot ) + cdr [ convert-form ] [ ] lmap-as [ 1 tail* ] [ but-last ] bi + [ [ drop ] compose ] map prepend '[ , [ call ] each ] ; : form-dispatch ( cons lisp-symbol -- quot ) name>> @@ -70,6 +74,7 @@ PRIVATE> { "defmacro" [ convert-defmacro ] } { "quote" [ convert-quoted ] } { "cond" [ convert-cond ] } + { "begin" [ convert-begin ] } [ drop convert-general-form ] } case ;