Skip to content

Commit c199357

Browse files
committed
feat(syntax)!: using 'macro' instead of '$' to define macros
1 parent a24e382 commit c199357

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

Macros.ark

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# internal, do not use
2-
($ __replace_all_placeholders_with (replacement x ...xs) {
2+
(macro __replace_all_placeholders_with (replacement x ...xs) {
33
($if (empty? xs)
44
($if (= "_" ($repr x))
55
replacement
@@ -12,33 +12,33 @@
1212
x
1313
(__replace_all_placeholders_with replacement ...xs) })) })
1414

15-
($ -> (arg fn1 ...fns) {
15+
(macro -> (arg fn1 ...fns) {
1616
($if (= "Symbol" ($type fn1))
17-
($ call (fn1 arg))
18-
($ call ((__replace_all_placeholders_with arg ...fn1))))
17+
(macro call (fn1 arg))
18+
(macro call ((__replace_all_placeholders_with arg ...fn1))))
1919
($if (> (len fns) 0)
2020
(-> call ...fns)
2121
call) })
2222

2323
# internal, do not use
24-
($ __suffix-dup (sym x) {
24+
(macro __suffix-dup (sym x) {
2525
($if (> x 1) (__suffix-dup sym (- x 1)))
2626
($symcat sym x) })
2727

28-
($ partial (func ...defargs) {
29-
($ bloc (__suffix-dup a (- ($argcount func) (len defargs))))
28+
(macro partial (func ...defargs) {
29+
(macro bloc (__suffix-dup a (- ($argcount func) (len defargs))))
3030
(fun (bloc) (func ...defargs bloc))
3131
($undef bloc) })
3232

33-
($ __count_placeholders (acc x ...xs) ($if (empty? xs)
33+
(macro __count_placeholders (acc x ...xs) ($if (empty? xs)
3434
($if (= "_" ($repr x))
3535
(+ 1 acc)
3636
acc)
3737
($if (= "_" ($repr x))
3838
(__count_placeholders (+ 1 acc) ...xs)
3939
(__count_placeholders acc ...xs))))
4040

41-
($ __replace_placeholders (replacements x ...xs) {
41+
(macro __replace_placeholders (replacements x ...xs) {
4242
($if (empty? xs)
4343
($if (= "_" ($repr x))
4444
(head replacements)
@@ -52,14 +52,14 @@
5252

5353
(__replace_placeholders replacements ...xs) })) })
5454

55-
($ partial2 (call ...args) {
56-
($ length (__count_placeholders 0 ...args))
57-
($ arg_bloc (__suffix-dup arg length))
58-
($ all_args (__replace_placeholders [arg_bloc] ...args))
55+
(macro partial2 (call ...args) {
56+
(macro length (__count_placeholders 0 ...args))
57+
(macro arg_bloc (__suffix-dup arg length))
58+
(macro all_args (__replace_placeholders [arg_bloc] ...args))
5959
(fun (arg_bloc) (call all_args)) })
6060

61-
($ unless (cond ...body)
61+
(macro unless (cond ...body)
6262
(if (not cond) ...body))
6363

64-
($ until (cond body)
64+
(macro until (cond body)
6565
(while (not cond) body))

Switch.ark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# _ (print "default"))
1414
# =end
1515
# @author https://github.com/SuperFola
16-
($ switch (value case then ...cases) {
16+
(macro switch (value case then ...cases) {
1717
($if (= "_" ($repr case))
1818
then
1919
(if (= value case)

Testing.ark

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
# (test:eq 1 2 "1 is 2, this should fail")})
9393
# =end
9494
# @author https://github.com/SuperFola
95-
($ test:case (_desc _body) {
95+
(macro test:case (_desc _body) {
9696
(mut _old_pointer testing:_suite.case_pointer)
9797

9898
# Add the test name to a pile so that we can nicely print all the case names later.
@@ -192,7 +192,7 @@
192192
# (test:expect (return_true) "return true"})
193193
# =end
194194
# @author https://github.com/SuperFola
195-
($ test:expect (_cond ..._desc) {
195+
(macro test:expect (_cond ..._desc) {
196196
(if (!= true ($as-is _cond))
197197
(testing:_report_error true ($as-is _cond) "true" ($repr _cond) _desc)
198198
(testing:_report_success)) })
@@ -207,7 +207,7 @@
207207
# (test:eq 5 (foo) "foo should return 5")})
208208
# =end
209209
# @author https://github.com/SuperFola
210-
($ test:eq (_expected _expr ..._desc) {
210+
(macro test:eq (_expected _expr ..._desc) {
211211
(if (= ($as-is _expected) ($as-is _expr))
212212
(testing:_report_success)
213213
(testing:_report_error ($as-is _expected) ($as-is _expr) ($repr _expected) ($repr _expr) _desc)) })
@@ -221,7 +221,7 @@
221221
# (test:neq 0 (my_function 1 2 3))})
222222
# =end
223223
# @author https://github.com/SuperFola
224-
($ test:neq (_unexpected _value ..._desc) {
224+
(macro test:neq (_unexpected _value ..._desc) {
225225
(if (!= ($as-is _unexpected) ($as-is _value))
226226
(testing:_report_success)
227227
(testing:_report_error ($as-is _unexpected) ($as-is _value) ($repr _unexpected) ($repr _value) _desc)) })
@@ -237,7 +237,7 @@
237237
# (test:eq 128 (* 8 16))})
238238
# =end
239239
# @author https://github.com/SuperFola
240-
($ test:suite (_name _body) {
240+
(macro test:suite (_name _body) {
241241
(set testing:_suite (testing:_make_suite ($repr _name)))
242242

243243
(let ($symcat _name "-output") (testing:_runner

0 commit comments

Comments
 (0)