Skip to content

hellerve-project-based-learning/dbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

dbc

A design-by-contract system for zepto. Built for an upcoming blog post on Scheme macros. Inspired by ds2643’s implementation in Common Lisp.

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:

(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!

About

A toy design-by-contract system for zepto

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published