- (let* ((e (find-entities-by-components components ',component-types))
- (e* (map (lambda (x) (assoc x entities)) e))
- (e** (map (lambda (x) (cons (car x) (filter (lambda (x) (memq (car x) ',component-types)) (cdr x)))) e*))
- (res (func e**)))
- (lambda* (#:optional (entities2 #f) (components2 #f))
- (let ((e (if (and entities2 components2) entities2 entities))
- (c (if (and entities2 components2) components2 components)))
- (modify-entities res e c)))))))
-
-
-(define-macro (define-system head system-func)
- (let ((name (car head))
- (component-types (cdr head)))
- `(define ,name (make-system ,component-types ,system-func))))
-
+ (let ((name (map (lambda (x)
+ (cons (car x)
+ (filter (lambda (x)
+ (memq (car x) '(component-type ...)))
+ (cdr x))))
+ (map (lambda (x)
+ (assoc x entities))
+ (find-entities-by-components components '(component-type ...)))))
+ ...)
+ (let ((res (begin form ...)))
+ (lambda* (#:optional (entities2 #f) (components2 #f))
+ (let ((e (if (and entities2 components2) entities2 entities))
+ (c (if (and entities2 components2) components2 components)))
+ (modify-entities res e c)))))))))
+
+(define-syntax define-system
+ (syntax-rules ()
+ ((_ system-name ((name (component-type ...)) ...) form ...)
+ (define system-name
+ (make-system ((name (component-type ...)) ...)
+ form
+ ...)))))