The Racket repository
![]() Specifically, remove reliance on procedure-closure-contents-eq? to tell when a pending check is stronger in favor of usint contract-stronger? Also, tighten up the specification of contract-stronger? to require that any contract is stronger than itself With this commit, this program gets about 10% slower: #lang racket/base (require racket/contract/base) (define f (contract (-> any/c integer?) (λ (x) (if (zero? x) 0 (f (- x 1)))) 'pos 'neg)) (time (f 2000000)) becuase the checking is doing work more explicitly now but because the checking in more general, it identifies the redundant checking in this program #lang racket/base (require racket/contract/base) (define f (contract (-> any/c integer?) (contract (-> any/c integer?) (λ (x) (if (zero? x) 0 (f (- x 1)))) 'pos 'neg) 'pos 'neg)) (time (f 200000)) which makes it run about 13x faster than it did before I'm not sure if this is a win overall, since the checking can be more significant in the case of "near misses". For example, with this program, where neither the new nor the old checking detects the redundancy is about 40% slower after this commit than it was before: #lang racket/base (require racket/contract/base) (define f (contract (-> any/c (<=/c 0)) (contract (-> any/c (>=/c 0)) (λ (x) (if (zero? x) 0 (f (- x 1)))) 'pos 'neg) 'pos 'neg)) (time (f 50000)) (The redundancy isn't detected here because the contract system only looks at the first pending contract check.) Overall, despite the fact that it slows down some programs and speeds up others, my main thought is that it is worth doing because it eliminates a (painful) reliance on procedure-closure-contents-eq? that inhibits other approaches to optimizing these contracts we might try. |
||
---|---|---|
pkgs | ||
racket | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.travis.yml | ||
appveyor.yml | ||
INSTALL.txt | ||
Makefile | ||
README.txt |
This is the source code for the main Racket distribution. See "INSTALL.txt" for information on building Racket. License ------- Racket Copyright (c) 2010-2015 PLT Design Inc. Racket is distributed under the GNU Lesser General Public License (LGPL). This implies that you may link Racket into proprietary applications, provided you follow the rules stated in the LGPL. You can also modify Racket; if you distribute a modified version, you must distribute it under the terms of the LGPL, which in particular states that you must release the source code for the modified software. See racket/src/COPYING_LESSER.txt for more information.