@@ -17,13 +17,13 @@ features, [like this][9].
17
17
18
18
; Only include given statement if `$DEBUG` environment variable is set
19
19
(macro debug
20
- (function (statement)
20
+ (lambda (statement)
21
21
(return (?: (. process env DEBUG)
22
22
statement
23
23
null))))
24
24
25
25
(var fib ; Fibonacci number sequence
26
- (function (x)
26
+ (lambda (x)
27
27
(debug ((. console log) (+ "resolving number " x)))
28
28
(switch x
29
29
(0 (return 0))
@@ -202,12 +202,13 @@ it's so common, other macros that accept a block statement as their last
202
202
argument have sugar for this: they just assume you meant the rest to be in a
203
203
block.
204
204
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.
207
208
208
209
<!-- !test in func and call -->
209
210
210
- (var f (function (x)
211
+ (var f (lambda (x)
211
212
(a x)
212
213
(return (+ x 2))))
213
214
(f 40)
@@ -290,7 +291,7 @@ computations.
290
291
291
292
<!-- !test in macro and call -->
292
293
293
- (macro m (function (x) (return `(+ ,x 2))))
294
+ (macro m (lambda (x) (return `(+ ,x 2))))
294
295
((. console log) (m 40))
295
296
296
297
<!-- !test out macro and call -->
@@ -303,7 +304,7 @@ the argument and returns the result.
303
304
304
305
<!-- !test in evaluate in macro -->
305
306
306
- (macro add2 (function (x) (return `,(+ ((. this evaluate) x) 2))))
307
+ (macro add2 (lambda (x) (return `,(+ ((. this evaluate) x) 2))))
307
308
((. console log) (add2 40))
308
309
309
310
<!-- !test out evaluate in macro -->
@@ -314,7 +315,7 @@ You can return multiple statements from a macro with `this.multi`.
314
315
315
316
<!-- !test in multiple-return macro -->
316
317
317
- (macro log-and-delete (function (varName)
318
+ (macro log-and-delete (lambda (varName)
318
319
(return ((. this multi)
319
320
`((. console log) ((. JSON stringify) ,varName))
320
321
`(delete ,varName)))))
@@ -332,7 +333,7 @@ compilation side-effects or conditional compilation.
332
333
<!-- !test in nothing-returning macro -->
333
334
334
335
; Only include statement if `$DEBUG` environment variable is set
335
- (macro debug (function (statement)
336
+ (macro debug (lambda (statement)
336
337
(return (?: (. process env DEBUG) statement null))))
337
338
338
339
(debug ((. console log) "debug output"))
@@ -349,11 +350,11 @@ shared between them.
349
350
350
351
<!-- !test in macros block -->
351
352
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)))))))
357
358
358
359
(increment)
359
360
(increment)
0 commit comments