https://github.com/hellerve/dbc
A toy design-by-contract system for zepto
https://github.com/hellerve/dbc
Last synced: about 1 year ago
JSON representation
A toy design-by-contract system for zepto
- Host: GitHub
- URL: https://github.com/hellerve/dbc
- Owner: hellerve
- Created: 2018-10-28T17:21:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-31T15:59:57.000Z (over 7 years ago)
- Last Synced: 2025-02-12T05:12:20.479Z (over 1 year ago)
- Size: 1000 Bytes
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dbc
A design-by-contract system for [zepto](https://github.com/zepto-lang/zepto).
Built for an upcoming blog post on Scheme macros. Inspired by [ds2643’s
implementation in Common Lisp](https://github.com/ds2643/dbc).
## Usage
This is an overly simple design-by-contract system expressed in a single macro.
It understands pre- and post-conditions. Its syntax looks a little like that:
```scheme
(defcontract (double xs)
(pre (list? xs) (all? number? xs))
(post (list? *ret*) (all? number? *ret*))
(map (lambda (x) (* x 2)) xs))
```
The variable `*ret*` is the return value of the function, and it’s available for
all post-conditions.
For more information about what it is and how to build something like this
yourself, [stay tuned for the blog post](//blog.veitheller.de/scheme-macros)!