Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can in fact define a fixed point combinator in good old C99, one that compiles without warning, and doesn't take all that much code.

From http://www.ioccc.org/2014/whowon.html

   Most functional
   Freek Wiedijk - Y combinator
We'll have to patiently await publication of the source though...


The Y combinator causes problems with typing (it has an infinite recursive type), so I'm curious what solution they came up with.

In any case, if calling a lambda function from within itself is going to take more than a single line of straightforward code, then I'm afraid the solution still doesn't cut it for practical purposes.


so I'm curious what solution they came up with.

I'm guessing a cast. The infinitely long type is not at all a problem in languages with weak type systems like C.


They could've done something similar to what you do when you implement a functional language in C and used a union to represent every possible return type, and included functions (closures if you will) in that union, then you solve the problem of the infinite type.


why does this matter, what is the overwhelming use case for self referential anonymous functions.


Do you have any code examples?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: