Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/quote-bad
A version of quote that helps to rid programs of potential bad uses of quote
https://github.com/alexknauth/quote-bad
Last synced: about 1 month ago
JSON representation
A version of quote that helps to rid programs of potential bad uses of quote
- Host: GitHub
- URL: https://github.com/alexknauth/quote-bad
- Owner: AlexKnauth
- License: mit
- Created: 2016-05-28T18:22:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T04:05:21.000Z (4 months ago)
- Last Synced: 2024-10-16T02:55:02.414Z (3 months ago)
- Language: Racket
- Homepage:
- Size: 32.2 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
quote - bad
===
A version of quote that helps to rid programs of bad uses of quote.documentation: http://docs.racket-lang.org/quote-bad/index.html
The `quote` form can seem convenient as a shorthand, but it can
lead to many common mistakes. Most of these mistakes come from people
not understanding that a quoted form also quotes its sub-expressions.In a file that requires this library, using `quote` for
compound data will cause an error with a message telling you how to
write it without `quote`, and "self-quoting" compound data
literals such as vector literals will display a similar error
explaining how to write the same thing without them.Examples:
```racket
> (require quote-bad/quote-bad)
> 'hello
'hello
> '"this is fine"
"this is fine"
> '#:of-course
'#:of-course
> '(1 2 (+ 1 2))
;. quote: Don't use quote for this. Instead you can use
;(list 1 2 (list '+ 1 2))
; in: (quote (1 2 (+ 1 2)))
> (list 1 2 (list '+ 1 2))
(list 1 2 (list '+ 1 2))
> (list 1 2 (+ 1 2))
(list 1 2 3)
> #(1 2 (+ 1 2))
;. #%datum: Don't use self-quoting compound literals that implicitly quote sub-expressions.
;Instead you can use
;(vector-immutable 1 2 (list '+ 1 2))
; in: (#%datum . #(1 2 (+ 1 2)))
> (vector-immutable 1 2 (list '+ 1 2))
(vector-immutable 1 2 (list '+ 1 2))
> (vector-immutable 1 2 (+ 1 2))
(vector-immutable 1 2 3)
```