From d3c91164aff6a620348c81776fdae37fa41b81c3 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 9 May 2024 18:18:15 -0700 Subject: docs: update for previous commit accordingly --- docs/METAPROGRAMMING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs/METAPROGRAMMING.md') 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()? -- cgit v1.2.3-70-g09d2