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

Yes, but functions aren't truly first-class values; you cannot create new ones on-the-fly (proprietary extensions notwithstanding).


What does proprietary mean in this context? I'm sure it can be copied/implemented by for example gcc if they were interested.


I meant to refer to extensions implemented independently by one compiler or another. Clang and gcc both provide lambdas, but not in the same way, and there's no standard for it. (I could be wrong on both points; this is purely from memory, and could have changed.)


Thanks for your explanation. I had to look and I libblocksruntime which seems to be an open source lib for clang with blocks.


Actually, if you look closely you'll notice that not other language lets you do this either (except through an 'eval' or similar). What I think you actually mean is that this still doesn't let you use closures. But in fact it does! :D You'll have to do a lot of void * casting to make it work though.


C does not provide closures. You can pass around a struct with a function pointer and a data or state pointer though. That will let you achieve the same thing, but it won't be as pretty.




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

Search: