-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#lang racket/base | ||
(module+ test | ||
(require rackunit syntax-parse-example/defines/defines) | ||
|
||
(test-case "quot/rem" | ||
(defines | ||
[x 4] | ||
[y 18] | ||
[(quot rem) (quotient/remainder x y)]) | ||
(check-equal? quot 0) | ||
(check-equal? rem 4)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#lang racket | ||
(provide defines) | ||
(require syntax/parse/define) | ||
|
||
(define-syntax-parser defines | ||
[(_ (~or [id:id expr:expr] | ||
[(idv:id ...+) expr:expr]) ...+) | ||
#'(begin | ||
(~? (define id expr) | ||
(define-values (idv ...) expr)) ...)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#lang syntax-parse-example | ||
@require[ | ||
(for-label racket/base syntax/parse syntax-parse-example/defines/defines)] | ||
|
||
@(define defines-eval | ||
(make-base-eval '(require syntax-parse-example/defines/defines))) | ||
|
||
@title{@tt{defines}} | ||
@stxbee2021["Fictitious-Rotor" 7] | ||
|
||
@; ============================================================================= | ||
|
||
@defmodule[syntax-parse-example/defines/defines]{} | ||
|
||
@defform[(defines expr ...)]{ | ||
Make a sequence of definitions --- similar to @racket[let*]. | ||
|
||
Definitions are automatically dispatched either to @racket[define] or @racket[define-values] | ||
depending on the manner in which identifiers are supplied. | ||
|
||
@examples[#:eval defines-eval | ||
(defines | ||
[x 4] | ||
[y 18] | ||
[(quot rem) (quotient/remainder x y)]) | ||
quot | ||
rem | ||
] | ||
|
||
The macro uses the @racket[~?] fallthrough syntax to choose between | ||
@racket[define] and @racket[define-values]. | ||
|
||
@racketfile{defines.rkt} | ||
|
||
@; TODO add description here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters