by combining wisp with sc, which both only depend on guile, it is possible to write c with indent and with less brackets similar to coffeescript or python.
sc is a scheme-like notation for c, similar to an abstract syntax tree. it can be used on its own to write c. wisp, whitespace to lisp, is a notation for scheme expressions that allows for indent in place of round brackets. wisp and sc are both quite complete and schemes basic syntax, which both support, of course too.
pre-include "stdio.h" define (main argc argv) : int int char** declare i int printf "the number of program arguments passed is %d\n" argc for : (set i 0) (< i argc) (set+ i 1) printf "argument %d is %s\n" (+ i 1) (array-get argv i) return 0
#!/usr/bin/guile !# ; example usage: ; cat t.w | wisp2lisp (import (wisp) (rnrs io ports)) (display (wisp2lisp (get-string-all (current-input-port))))
take a file with contents that use wisp syntax with sc semantics and compile to standard output with the following shell command:
cat myfile.scw | wisp2lisp | sc
write to file:
cat myfile.scw | wisp2lisp | sc > output.c
formatted with clang-format:
cat myfile.scw | wisp2lisp | sc | clang-format
as the author of sc, i used sc in several c projects and found that with the imperative style of c, each line tends to be a command and that with scheme-like syntax that means it starts with a round bracket. this unfortunately appears quite noisy, to the point that it might make things more difficult with all the little commands and declaration and memory-management code overhead in c.
sc now comes with a file other/wisp2sc which uses standard input/output and only changes the way associations are made to require less syntax. this makes it possible to use this in declare and all similar forms:
declare a 1 b 2
instead of having to use a dot, since sc on its own currently takes associations as a flat list (key value key value ...)
declare . a 1 . b 2