Optimization
Match a rule
Section titled “Match a rule”Given a file named “main.scm” with:
(import (scheme base) (scheme write) (stak base))
(define-optimizer foo (syntax-rules () ((foo) (write 42))))
(foo)When I successfully run stak main.scm
Then the stdout should contain exactly “42”.
Match a variable pattern
Section titled “Match a variable pattern”Given a file named “main.scm” with:
(import (scheme base) (scheme write) (stak base))
(define-optimizer foo (syntax-rules () ((foo x) (write x))))
(foo 42)When I successfully run stak main.scm
Then the stdout should contain exactly “42”.
Match an ellipsis pattern
Section titled “Match an ellipsis pattern”Given a file named “main.scm” with:
(import (scheme base) (scheme write) (stak base))
(define-optimizer foo (syntax-rules () ((foo x ...) (write (list x ...)))))
(foo 1 2 3)When I successfully run stak main.scm
Then the stdout should contain exactly “(1 2 3)”.