Optimization
Match a rule
Section titled “Match a rule”Given a file named “main.scm” with:
(import (scheme base) (stak base))
(define-optimizer foo (syntax-rules () ((foo) (write-u8 65))))
(foo)When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Match a variable pattern
Section titled “Match a variable pattern”Given a file named “main.scm” with:
(import (scheme base) (stak base))
(define-optimizer foo (syntax-rules () ((foo x) (write-u8 x))))
(foo 65)When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Match an ellipsis pattern
Section titled “Match an ellipsis pattern”Given a file named “main.scm” with:
(import (scheme base) (stak base))
(define-optimizer foo (syntax-rules () ((foo x ...) (for-each write-u8 (list x ...)))))
(foo 65 66 67)When I successfully run stak main.scm
Then the stdout should contain exactly “ABC”.