this post was submitted on 17 Dec 2025
516 points (96.2% liked)

Programmer Humor

28424 readers
1604 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] cryoistalline@lemmy.ml 4 points 3 weeks ago (1 children)

types in C are pretty weird

int *a can be read as

  1. *a is a int
  2. since dereferencing is a operator on pointers, a is a pointer to int

int *a, b is read as

  1. *a and b are int
  2. so a is a pointer to int and b is a int

bool getofmylawn(Lawn lawn)

  1. getoffmylawn(Lawn lawn) is a bool
  2. since calling is done on functions, getoffmylawn is a function that takes a Lawn and returns a bool

And then you have function pointers

bool (*foo(int a))(float b)

  1. (*foo(int a))(float b) is a bool
  2. *foo(int a) is a function from float to bool
  3. foo(int a) is a function pointer from float to bool
  4. foo is a function that takes a int and returns a function pointer from float to bool

really weird in my opinion.

C++ is even worse, due to templates and the so-called most vexing parse. Initializing with {} mitigated the latter somewhat, but came with its own set of woes