Skip to content

Commit 998af3e

Browse files
committed
Readme: Update for new function macro names
1 parent e975034 commit 998af3e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

readme.markdown

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ features, [like this][9].
1717

1818
; Only include given statement if `$DEBUG` environment variable is set
1919
(macro debug
20-
(function (statement)
20+
(lambda (statement)
2121
(return (?: (. process env DEBUG)
2222
statement
2323
null))))
2424

2525
(var fib ; Fibonacci number sequence
26-
(function (x)
26+
(lambda (x)
2727
(debug ((. console log) (+ "resolving number " x)))
2828
(switch x
2929
(0 (return 0))
@@ -202,12 +202,13 @@ it's so common, other macros that accept a block statement as their last
202202
argument have sugar for this: they just assume you meant the rest to be in a
203203
block.
204204

205-
For example. the `function` macro treats its first argument as a list of the
206-
function's argument names, and the rest as statements in the function body.
205+
For example. the `lambda` macro (which creates function expressions) treats its
206+
first argument as a list of the function's argument names, and the rest as
207+
statements in the body.
207208

208209
<!-- !test in func and call -->
209210

210-
(var f (function (x)
211+
(var f (lambda (x)
211212
(a x)
212213
(return (+ x 2))))
213214
(f 40)
@@ -290,7 +291,7 @@ computations.
290291

291292
<!-- !test in macro and call -->
292293

293-
(macro m (function (x) (return `(+ ,x 2))))
294+
(macro m (lambda (x) (return `(+ ,x 2))))
294295
((. console log) (m 40))
295296

296297
<!-- !test out macro and call -->
@@ -303,7 +304,7 @@ the argument and returns the result.
303304

304305
<!-- !test in evaluate in macro -->
305306

306-
(macro add2 (function (x) (return `,(+ ((. this evaluate) x) 2))))
307+
(macro add2 (lambda (x) (return `,(+ ((. this evaluate) x) 2))))
307308
((. console log) (add2 40))
308309

309310
<!-- !test out evaluate in macro -->
@@ -314,7 +315,7 @@ You can return multiple statements from a macro with `this.multi`.
314315

315316
<!-- !test in multiple-return macro -->
316317

317-
(macro log-and-delete (function (varName)
318+
(macro log-and-delete (lambda (varName)
318319
(return ((. this multi)
319320
`((. console log) ((. JSON stringify) ,varName))
320321
`(delete ,varName)))))
@@ -332,7 +333,7 @@ compilation side-effects or conditional compilation.
332333
<!-- !test in nothing-returning macro -->
333334

334335
; Only include statement if `$DEBUG` environment variable is set
335-
(macro debug (function (statement)
336+
(macro debug (lambda (statement)
336337
(return (?: (. process env DEBUG) statement null))))
337338

338339
(debug ((. console log) "debug output"))
@@ -349,11 +350,11 @@ shared between them.
349350

350351
<!-- !test in macros block -->
351352

352-
(macro ((function ()
353-
(var x 0) ; this is visible to all of the macro functions
354-
(return (object increment (function () (return (++ x)))
355-
decrement (function () (return (-- x)))
356-
get (function () (return x)))))))
353+
(macro ((lambda ()
354+
(var x 0) ; visible to all of the macro functions
355+
(return (object increment (lambda () (return (++ x)))
356+
decrement (lambda () (return (-- x)))
357+
get (lambda () (return x)))))))
357358

358359
(increment)
359360
(increment)

0 commit comments

Comments
 (0)