3 ms·
Show HN: Computation at Compile-Time now free online
- billsix 9y agoAuthor here. 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.
- agumonkey 9y agoThanks for this interesting topic. ps: is `[|y| (cons x y)]` standard notation in gambit ?
- agumonkey 9y agoalso one link causes https issues, but can be read through the WaybackMachine https://web.archive.org/web/20151012023906/http://mercure.iro.umontreal.ca/pipermail/gambit-list/2012-April/005917.html https://web.archive.org/web/20151012023906/http://mercure.ir...
- billsix 9y agoThanks! Will update
- dtornabene 9y agothis 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.
- chriswarbo 9y agoLooks 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 http://ziglang.org
- k__ 9y agoComing from things like Babel I was really amazed what the OCaml compiler could do at compile time.
- kwhitefoot 9y agoSounds 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.
- billsix 9y agoThanks for the reference on doctests. 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.