@@ -149,31 +149,32 @@ generate arbitrary JavaScript are built in to eslisp.
149
149
150
150
### General
151
151
152
- | name | description |
153
- | ---------- | ---------------------------- |
154
- | ` array ` | array literal |
155
- | ` object ` | object literal |
156
- | ` regex ` | regular expression literal |
157
- | ` var ` | variable declaration |
158
- | ` . ` | member expression |
159
- | ` get ` | * computed* member expression |
160
- | ` switch ` | switch statement |
161
- | ` if ` | conditional statement |
162
- | ` ?: ` | ternary expression |
163
- | ` while ` | while loop |
164
- | ` dowhile ` | do-while loop |
165
- | ` for ` | for loop |
166
- | ` forin ` | for-in loop |
167
- | ` break ` | break statement |
168
- | ` continue ` | continue statement |
169
- | ` label ` | labeled statement |
170
- | ` label ` | labeled statement |
171
- | ` function ` | function expression |
172
- | ` return ` | return statement |
173
- | ` new ` | new-expression |
174
- | ` debugger ` | debugger statement |
175
- | ` throw ` | throw statement |
176
- | ` try ` | try-catch statement |
152
+ | name | description |
153
+ | ----------------- | ---------------------------- |
154
+ | ` array ` | array literal |
155
+ | ` object ` | object literal |
156
+ | ` regex ` | regular expression literal |
157
+ | ` var ` | variable declaration |
158
+ | ` . ` | member expression |
159
+ | ` get ` | * computed* member expression |
160
+ | ` switch ` | switch statement |
161
+ | ` if ` | conditional statement |
162
+ | ` ?: ` | ternary expression |
163
+ | ` while ` | while loop |
164
+ | ` dowhile ` | do-while loop |
165
+ | ` for ` | for loop |
166
+ | ` forin ` | for-in loop |
167
+ | ` break ` | break statement |
168
+ | ` continue ` | continue statement |
169
+ | ` label ` | labeled statement |
170
+ | ` label ` | labeled statement |
171
+ | ` function ` | function expression |
172
+ | ` declarefunction ` | function declaration |
173
+ | ` return ` | return statement |
174
+ | ` new ` | new-expression |
175
+ | ` debugger ` | debugger statement |
176
+ | ` throw ` | throw statement |
177
+ | ` try ` | try-catch statement |
177
178
178
179
#### Structural
179
180
@@ -414,6 +415,8 @@ the `default`-case clause.
414
415
415
416
### Functions
416
417
418
+ #### Function expressions
419
+
417
420
The ` function ` macro creates function expressions. Its first argument becomes
418
421
the argument list, and the rest become statements in its body. The ` return `
419
422
macro compiles to a return-statement.
@@ -429,7 +432,6 @@ macro compiles to a return-statement.
429
432
return 5 * (a * b);
430
433
};
431
434
432
-
433
435
You can also give a name to a function expression as the optional first
434
436
argument, if you so wish.
435
437
@@ -443,6 +445,20 @@ argument, if you so wish.
443
445
return 'T';
444
446
};
445
447
448
+ #### Function declarations
449
+
450
+ These work much like function expressions above, but require a name.
451
+
452
+ <!-- !test in function declaration -->
453
+
454
+ (declarefunction tea () (return "T"))
455
+
456
+ <!-- !test out function declaration -->
457
+
458
+ function tea() {
459
+ return 'T';
460
+ }
461
+
446
462
### Loops
447
463
448
464
While-loops (with the ` while ` macro) take the first argument to be the loop
0 commit comments