r/ProgrammerHumor • • Oct 24 '26

Meme dreamLanguage

Post image
1.4k Upvotes

211 comments sorted by

View all comments

Show parent comment

99

u/UdPropheticCatgirl Oct 24 '26

int (*(*signal(int, int (*)(int)))(int))(int);

The elegance and simplicity of C is truly unmatched

12

u/frikilinux2 Oct 24 '26

So for you C belongs in hell, doesn't it?

20

u/UdPropheticCatgirl Oct 24 '26

I mean how could it belong anywhere else?

2

u/frikilinux2 Oct 24 '26

Ok but can you find me an example of so many pointers. I accept s link to kernel.org or something like that

17

u/UdPropheticCatgirl Oct 24 '26

I mean my declaration is not completely made up...

It's just fairly standard linux sig hangler, except most other codebases would use actual typedefs and macros to split it into multiple declarations see here and here.

7

u/frikilinux2 Oct 24 '26

Ok, I'll accept it.

4

u/DeVinke_ Oct 24 '26

If this is the elegance of your c code, you're definitely going to hell.

-4

u/Kadabrium Oct 24 '26

The joke here is arrays of higher order functions don't even exist in functional languages, because they dont use arrays lol

7

u/UdPropheticCatgirl Oct 24 '26

The joke here is arrays of higher order functions don't even exist in functional languages, because they dont use arrays lol

You realize, that there are no arrays in that C type right?

In Scala it would be:

type Signal = (Int, Int => Int) => (Int => (Int => Int))

also I struggle to think of somewhat mainstream functional language without arrays...

In haskell you could do:

import Data.Array
funcs :: Array Int (Int -> Int)
funcs = listArray (0, 2) [id, (+1), (*2)]

, in OCaml:

let funcs : (int -> int) array =
  [| (fun x -> x); (fun x -> x + 1); (fun x -> x * 2) |]

and in Scala:

val funcs: Array[Int => Int] =
  Array(
    x => x,
    x => x + 1,
    x => x * 2
  )