The book is about augmenting the Gambit Scheme compiler with the code which it is compiling, thus treating the compiler as an interpreter. Testing dominates the compile-time computation, as each procedure in the book is collocated with tests for that procedure. Should any test fail, the library fails to compile, like a type error in a statically-typed language.
this looks awesome, thanks for sharing it with the community for free. I've had it book marked from another site elsewhere for a couple weeks now, can't wait to get into it.
Looks very nice. I've recently written a bunch of Racket, which also encourages tests to be written alongside definitions, although they're not run as part of compilation. However, I've actually ended up with similar functionality, by packaging these scripts using Nix and having a dependency which runs the test suite and aborts on failure.
It's nice to see more investigations going on into the nuances of programming "stages", rather than the usual compile vs interpret dogma.
Another approach which seems similar in spirit is Zig's use of compile-time execution http://ziglang.org
Sounds like an interesting idea. Reminds me a little of doctests in Python. This can also be applied to languages and compilers that do not allow the tests to run at compile time by wrapping the tests in #If DEBUG ... #End If or whatever the construct is in the language to compile the tests in debug mode only. Or define a special symbol WITHTESTS.
Then at least your tests will be close by the code that they are testing and they won't affect the size of the delivered binary.
14 comments
[ 4.0 ms ] story [ 22.5 ms ] threadThe book is about augmenting the Gambit Scheme compiler with the code which it is compiling, thus treating the compiler as an interpreter. Testing dominates the compile-time computation, as each procedure in the book is collocated with tests for that procedure. Should any test fail, the library fails to compile, like a type error in a statically-typed language.
ps: is `[|y| (cons x y)]` standard notation in gambit ?
[|y| (cons x y)] turns into (lambda (y) (cons x y))
https://web.archive.org/web/20151012023906/http://mercure.ir...
It's nice to see more investigations going on into the nuances of programming "stages", rather than the usual compile vs interpret dogma.
Another approach which seems similar in spirit is Zig's use of compile-time execution http://ziglang.org
Then at least your tests will be close by the code that they are testing and they won't affect the size of the delivered binary.
I encourage the collocation of tests with procedures in every language, but I personally doubt the efficacy of pound defines.
Assert macros are great, but how can a programmer guarantee that they are ever even invoked?
"mo' tests mo' problems" -Sean 'puff daddy" Combs.