aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux51
1 files changed, 27 insertions, 24 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index f530f9ca5..af5a0d142 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -5273,30 +5273,31 @@
(wrap (list (record$ =pairs))))
))
-(macro: #export (let% tokens)
+(macro: #export (with-expansions tokens)
{#;doc (doc "Controlled macro-expansion."
"Bind an arbitraty number of ASTs resulting from macro-expansion to local bindings."
"Wherever a binding appears, the bound ASTs will be spliced in there."
(test: "AST operations & structures"
- (let% [<tests> (do-template [<expr> <text> <pattern>]
- [(compare <pattern> <expr>)
- (compare <text> (:: AST/encode show <expr>))
- (compare true (:: Eq<AST> = <expr> <expr>))]
-
- [(bool true) "true" [_ (#;Bool true)]]
- [(bool false) "false" [_ (#;Bool false)]]
- [(int 123) "123" [_ (#;Int 123)]]
- [(real 123.0) "123.0" [_ (#;Real 123.0)]]
- [(char #"\n") "#\"\\n\"" [_ (#;Char #"\n")]]
- [(text "\n") "\"\\n\"" [_ (#;Text "\n")]]
- [(tag ["yolo" "lol"]) "#yolo;lol" [_ (#;Tag ["yolo" "lol"])]]
- [(symbol ["yolo" "lol"]) "yolo;lol" [_ (#;Symbol ["yolo" "lol"])]]
- [(form (list (bool true) (int 123))) "(true 123)" (^ [_ (#;Form (list [_ (#;Bool true)] [_ (#;Int 123)]))])]
- [(tuple (list (bool true) (int 123))) "[true 123]" (^ [_ (#;Tuple (list [_ (#;Bool true)] [_ (#;Int 123)]))])]
- [(record (list [(bool true) (int 123)])) "{true 123}" (^ [_ (#;Record (list [[_ (#;Bool true)] [_ (#;Int 123)]]))])]
- [(local-tag "lol") "#lol" [_ (#;Tag ["" "lol"])]]
- [(local-symbol "lol") "lol" [_ (#;Symbol ["" "lol"])]]
- )]
+ (with-expansions
+ [<tests> (do-template [<expr> <text> <pattern>]
+ [(compare <pattern> <expr>)
+ (compare <text> (:: AST/encode show <expr>))
+ (compare true (:: Eq<AST> = <expr> <expr>))]
+
+ [(bool true) "true" [_ (#;Bool true)]]
+ [(bool false) "false" [_ (#;Bool false)]]
+ [(int 123) "123" [_ (#;Int 123)]]
+ [(real 123.0) "123.0" [_ (#;Real 123.0)]]
+ [(char #"\n") "#\"\\n\"" [_ (#;Char #"\n")]]
+ [(text "\n") "\"\\n\"" [_ (#;Text "\n")]]
+ [(tag ["yolo" "lol"]) "#yolo;lol" [_ (#;Tag ["yolo" "lol"])]]
+ [(symbol ["yolo" "lol"]) "yolo;lol" [_ (#;Symbol ["yolo" "lol"])]]
+ [(form (list (bool true) (int 123))) "(true 123)" (^ [_ (#;Form (list [_ (#;Bool true)] [_ (#;Int 123)]))])]
+ [(tuple (list (bool true) (int 123))) "[true 123]" (^ [_ (#;Tuple (list [_ (#;Bool true)] [_ (#;Int 123)]))])]
+ [(record (list [(bool true) (int 123)])) "{true 123}" (^ [_ (#;Record (list [[_ (#;Bool true)] [_ (#;Int 123)]]))])]
+ [(local-tag "lol") "#lol" [_ (#;Tag ["" "lol"])]]
+ [(local-symbol "lol") "lol" [_ (#;Symbol ["" "lol"])]]
+ )]
(test-all <tests>))))}
(case tokens
(^ (list& [_ (#Tuple bindings)] bodies))
@@ -5304,21 +5305,23 @@
(^ (list& [_ (#Symbol ["" var-name])] macro-expr bindings'))
(do Monad<Lux>
[expansion (macro-expand-once macro-expr)]
- (case (place-tokens var-name expansion (` (;let% [(~@ bindings')] (~@ bodies))))
+ (case (place-tokens var-name expansion (` (;with-expansions
+ [(~@ bindings')]
+ (~@ bodies))))
(#Some output)
(wrap output)
_
- (fail "[let%] Improper macro expansion.")))
+ (fail "[with-expansions] Improper macro expansion.")))
#Nil
(return bodies)
_
- (fail "Wrong syntax for let%"))
+ (fail "Wrong syntax for with-expansions"))
_
- (fail "Wrong syntax for let%")))
+ (fail "Wrong syntax for with-expansions")))
(def: (flatten-alias type)
(-> Type Type)