-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support #:auto-value for defparam and defthing
Manually specifying `#:value` could be cumbersome. An example is `html-empty-tags` from the `xml` collection, which is a list of more than 10 symbols. It is also error-prone, and could be out-of-sync from the actual value. This PR adds a support for `#:auto-value` in `defparam` and `defthing` to automatically query the value from the `for-label` binding. The original idea of this PR is from racket/racket#4807. Thanks to @LiberalArtist who recommended an implementation strategy, and @rocketnia for feedback. .
- Loading branch information
Showing
6 changed files
with
163 additions
and
22 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
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
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,25 @@ | ||
#lang racket/base | ||
|
||
(provide check-marshalable) | ||
|
||
(require racket/fixnum | ||
racket/flonum | ||
racket/extflonum) | ||
|
||
;; check-marshalable : any/c -> (or/c #f any/c) | ||
(define (check-marshalable v) | ||
(let loop ([v v]) | ||
(cond | ||
[(or (null? v) (symbol? v) (number? v) (char? v) (keyword? v) | ||
(string? v) (bytes? v) | ||
(regexp? v) (byte-regexp? v) | ||
(fxvector? v) (flvector? v) (extflonum? v)) | ||
#f] | ||
[(pair? v) (or (loop (car v)) (loop (cdr v)))] | ||
[(box? v) (loop (unbox v))] | ||
[(vector? v) (for/or ([x (in-vector v)]) | ||
(loop x))] | ||
[(hash? v) (for/or ([(key val) (in-hash v)]) | ||
(or (loop key) (loop val)))] | ||
[(prefab-struct-key v) (loop (struct->vector v))] | ||
[else v]))) |
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
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
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