diff --git a/extra/lisp/lisp-tests.factor b/extra/lisp/lisp-tests.factor index c4090e1098..14b91aa58b 100644 --- a/extra/lisp/lisp-tests.factor +++ b/extra/lisp/lisp-tests.factor @@ -13,8 +13,6 @@ IN: lisp.test "+" "math" "+" define-primitive "-" "math" "-" define-primitive -! "list" [ >array ] lisp-define - { 5 } [ [ 2 3 ] "+" funcall ] unit-test @@ -55,8 +53,4 @@ IN: lisp.test "((lambda (x) (if x (begin (+ 1 2)) (- 3 5))) #t)" lisp-eval ] unit-test -! { { 1 2 3 4 5 } } [ -! "(list 1 2 3 4 5)" lisp-eval -! ] unit-test - ] with-interactive-vocabs diff --git a/extra/lisp/lisp.factor b/extra/lisp/lisp.factor index e865a2e3ed..425ee27bb7 100644 --- a/extra/lisp/lisp.factor +++ b/extra/lisp/lisp.factor @@ -59,10 +59,23 @@ PRIVATE> : convert-unquoted ( cons -- quot ) "unquote not valid outside of quasiquote!" throw ; -: convert-quasiquoted ( cons -- newcons ) +: convert-unquoted-splicing ( cons -- quot ) + "unquote-splicing not valid outside of quasiquote!" throw ; + +> "unquote" equal? dup ] } && nip ] [ cadr ] traverse ; +: quasiquote-unquote-splicing ( cons -- newcons ) + [ { [ dup list? ] [ dup cdr [ cons? ] [ car cons? ] bi and ] + [ dup cadr car lisp-symbol? ] [ cadr car name>> "unquote-splicing" equal? dup ] } && nip ] + [ dup cadr cdr >>cdr ] traverse ; +PRIVATE> + +: convert-quasiquoted ( cons -- newcons ) + quasiquote-unquote quasiquote-unquote-splicing ; + : convert-defmacro ( cons -- quot ) cdr [ car ] keep [ convert-lambda ] [ car name>> ] bi define-lisp-macro 1quotation ; @@ -72,6 +85,7 @@ PRIVATE> { "defmacro" [ convert-defmacro ] } { "quote" [ convert-quoted ] } { "unquote" [ convert-unquoted ] } + { "unquote-splicing" [ convert-unquoted-splicing ] } { "quasiquote" [ convert-quasiquoted ] } { "begin" [ convert-begin ] } { "cond" [ convert-cond ] } @@ -99,7 +113,7 @@ PRIVATE> call ; inline : macro-expand ( cons -- quot ) - uncons [ list>seq [ ] like ] [ lookup-macro macro-call compile-form ] bi* call ; + uncons [ list>seq [ ] like ] [ lookup-macro macro-call compile-form ] bi* ; : lisp-string>factor ( str -- quot ) lisp-expr parse-result-ast compile-form ; diff --git a/extra/lists/lazy/examples/examples-tests.factor b/extra/lists/lazy/examples/examples-tests.factor index d4e3ed79b8..c088f1d9a7 100644 --- a/extra/lists/lazy/examples/examples-tests.factor +++ b/extra/lists/lazy/examples/examples-tests.factor @@ -1,5 +1,5 @@ -USING: lazy-lists.examples lazy-lists tools.test ; -IN: lazy-lists.examples.tests +USING: lists.lazy.examples lazy-lists tools.test ; +IN: lists.lazy.examples.tests [ { 1 3 5 7 } ] [ 4 odds ltake list>array ] unit-test [ { 0 1 4 9 16 } ] [ first-five-squares ] unit-test