diff options
author | JJ | 2024-05-10 01:18:15 +0000 |
---|---|---|
committer | JJ | 2024-05-10 04:42:32 +0000 |
commit | d3c91164aff6a620348c81776fdae37fa41b81c3 (patch) | |
tree | ee52f6ff9fc5ec654618ec00a111ad0b4658b32c /docs/METAPROGRAMMING.md | |
parent | 073c902a31936c2b53d89245662fb272c9670169 (diff) |
docs: update for previous commit accordingly
Diffstat (limited to 'docs/METAPROGRAMMING.md')
-rw-r--r-- | docs/METAPROGRAMMING.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/METAPROGRAMMING.md b/docs/METAPROGRAMMING.md index b6a4165..a8675b2 100644 --- a/docs/METAPROGRAMMING.md +++ b/docs/METAPROGRAMMING.md @@ -10,7 +10,7 @@ Macros may not change Puck's syntax: the syntax is flexible enough. Code is synt **function scope**: takes the arguments within or following a function call ```puck macro print(params: varargs) = - for param in params: + for param in params do result.add(quote(stdout.write(`params`.str))) print(1, 2, 3, 4) @@ -21,7 +21,7 @@ print "hello", " ", "world", "!" ```puck macro my_macro(body) -my_macro: +my_macro 1 2 3 @@ -31,7 +31,7 @@ my_macro: **operator scope**: takes one or two parameters either as a postfix (one parameter) or an infix (two parameters) operator ```puck macro +=(a, b) = - quote: + quote `a` = `a` + `b` a += b @@ -47,10 +47,10 @@ As macros operate at compile time, they may not inspect the *values* that their ```puck macro ?[T, E](self: Result[T, E]) = - quote: + quote match self - of Okay(x): x - of Error(e): return Error(e) + of Okay(x) then x + of Error(e) then return Error(e) func meow: Result[bool, ref Err] = let a = stdin.get()? |