
Show HN: Computation at Compile-Time now free online - billsix
http://billsix.github.io/bug.html
======
billsix
Author 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
also one link causes https issues, but can be read through the WaybackMachine

[https://web.archive.org/web/20151012023906/http://mercure.ir...](https://web.archive.org/web/20151012023906/http://mercure.iro.umontreal.ca/pipermail/gambit-
list/2012-April/005917.html)

~~~
billsix
Thanks! Will update

------
chriswarbo
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](http://ziglang.org)

------
kwhitefoot
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.

~~~
billsix
Thanks 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.

------
k__
Coming from things like Babel I was really amazed what the OCaml compiler
could do at compile time.

~~~
billsix
With Gambit and libbug (my book), any computation can be done at compile time,
including state and I/O :-)

~~~
k__
Impossible O:

~~~
billsix
Not impossible, I do it in the book. I write both macro definitions and
namespace declarations to file during compile time! :-)

