Update (March 2013): C-REPL was a neat hack, but a more principled implementation of the same goal exists in Cling.

Many programming languages come with a REPL (read-eval-print loop), which allows you to type in code line by line and see what it does. This is quite useful for prototyping, experimentation, and debugging code.

Other programming languages, and especially C, use a "compile-run" model, and don't provide a REPL. Let's fix that.

What you get

This approach is actually more of a read-eval loop, as c-repl doesn't know much about the types and parse trees of the code it's running. But unlike other approaches to solving the "C interpreter" problem, c-repl works directly with unmodified libraries and system headers.

This means you can experiment with a new library without writing a test program or any bindings. Or just use it as a simple calculator, content in knowing it is much faster than your neighbors using irb , like driving a Ferarri on city streets.

Some especially cute frosting features: - tab-completion of in-scope symbols - inspection of in-scope variables (via the .t command)

Example Session

Here's an example session demonstrating using c-repl:

% ./c-repl > int x = 3 > ++x > .p x int: 4 > printf("%d %p

", x, &x) 4 0xb7f1b53c > .t fprintf fprintf(FILE* const stream, char const* const format) > #include <unistd.h> > getp<TAB> getpagesize getpass getpgid getpgrp getpid getppid > printf("%d

", getpid()) 19094

How to get and use it

See GitHub, but c-repl is unmaintained and I don't recommend you use it. This page is only of historical interest.