Fake anonymous functions in C

后端 未结 3 977
孤独总比滥情好
孤独总比滥情好 2021-02-05 15:23

In this SO thread, Brian Postow suggested a solution involving fake anonymous functions:

make a comp(L) function that returns the version of comp for arra

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 16:11

    It is not possible to generate ordinary functions during run-time in either C or C++. What Brian suggested is based on a big "if": "...if you can fake anonymous functions...". And the answer to that "if" is: no, you can't. (Although it is not clear what he meant by "fake".)

    (In C++ it is possible to generate function-like objects at run time, but not ordinary functions.)

    The above applies to standard C and C++ languages. Particular implementations can support various implementation-provided extensions and/or manually-implemented hacks, like "closures", "delegates" and similar stuff. Nothing of that, of course, have anything to do with standard C/C++ languages.

提交回复
热议问题