(compilation "-- -std=c11 -pedantic-errors") (input) (output "c11: 42 43 6 4 6 12 5 0 -9223372036854775808" "trigraphs: what??! ??= ???( ??/") (return 0) ;;; C11 is the floor, and this is the program that holds it there: the ;;; C every feature emits has to build under it with no extension, so ;;; one that reaches past it -- a GNU statement expression, a C23 ;;; keyword -- fails here rather than on a user's compiler. ;;; ;;; A capturing closure is the one that leans on C11 itself, through ;;; max_align_t in the environment and `_Static_assert' on its size; ;;; the record, the method and the match are here for what they emit, ;;; and the globals for initializers that have to be constants. ;;; ;;; It is also the one mode where C still reads trigraphs, which Sex has ;;; none of: a string says what was written, `??/' before its closing ;;; quote included. (include stdio.h) (record point ((x int) (y int))) (ops point (fn area ((self (* const point))) int (return (* (. self x) (. self y))))) (sum shape ((square ((side int))) (dot ()))) (var corner _ #(point : 2 3)) (var primes (* int) #([int 3] : 2 3 5)) (var origin point #()) (var unit _ (shape/square 1)) (var pair [_ 2] #(#(point : 1 2) #(point : 3 4))) (var least _ -9223372036854775808) (fn sides ((s shape)) int (var n int 0) (match s ((square (side)) (= n (* 4 side))) ((dot ()) (= n 0))) (return n)) (pub fn main () int (var p point #(point : 6 7)) (var k int 1) (var add-k (closure ((int)) int) (closure ((v int)) int (k) (return (+ v k)))) (printf "c11: %d %d %d %d %d %d %d %d %lld\n" (.area p) (add-k (.area p)) (+ (sides (shape/square 1)) (sides (shape/dot)) 2) (sides unit) (.area corner) (.area [pair 1]) [primes 2] (. origin y) least) (printf "trigraphs: %s\n" "what??! ??= ???( ??/") (return 0))