Showing the changes to src (1 of 2 files). Show all
Unified · Split
| @@ -2241,10 +2241,14 @@ · 2240 unmodified lines | ||
| 2241 | 2241 | (λ ,formals ,@body))) |
| 2242 | 2242 | |
| 2243 | 2243 | (defmacro (dotimes var . body) |
| 2244 | − (let ((v (car var)) | |
| 2245 | − (cnt (cadr var))) | |
| 2246 | − `(for 0 ,cnt | |
| 2247 | − (λ (,v) ,@body)))) | |
| 2244 | + (let* {[v (car var)] | |
| 2245 | + [cnt (aref var 1)] | |
| 2246 | + [nv (length var)] | |
| 2247 | + [res (if (= nv 3) (aref var 2) #.(void))]} | |
| 2248 | + (unless (<= nv 3) | |
| 2249 | + (compile-error "invalid var expression: " var)) | |
| 2250 | + `(begin (for 0 ,cnt (λ (,v) ,@body)) | |
| 2251 | + ,res))) | |
| 2248 | 2252 | |
| 2249 | 2253 | (defmacro (with-bindings binds . body) |
| 2250 | 2254 | (let ((vars (map car binds)) |