Implicitly Typed C

December 11th, 2023
tech
I don't know any good reason to do this, but if you would rather be writing Python or JavaScript here's something you can do with a C compiler:

$ cat tmp.c
foo(x) {
  return x+5;
}
bar() {
  return 4;
}
main() {
  printf("%d\n", foo(bar()));
}

$ gcc -w -o tmp.out tmp.c && ./tmp.out
9

This code takes advantage of a historical quirk of C where types are assumed to be int unless otherwise specified: foo(x) {...} is equivalent to int foo(int x) {...}. Additionally the printf works because gcc includes stdio.h by default, and main is special-cased to assume a final return 0.

I've occasionally used this style when writing example code to remove visual noise, but it's probably not a good idea there either.

Comment via: facebook, lesswrong, mastodon, substack

Recent posts on blogs I like:

Borderlines aren’t unusually attractive

Slutstack recently wrote an article advising women to adopt some of the traits of the hot-but-crazy BPD girl in order to appeal to men.

via Thing of Things November 21, 2026

Nora's Game Flaws

Today I was sitting in the living room reading a book, and my little sister Nora was sitting on the floor playing with these little lego people, but they look more like people than most lego people. There kept being flaws in her game, but she wouldn't…

via Anna Wise's Blog Posts November 21, 2026

I did a meditation and it sort of changed my personality?!

a trip report

via benkuhn.net November 8, 2026

more     (via openring)