Hacker News new | past | comments | ask | show | jobs | submit login

Add is a piece of data, not a function. The equivalent in C would be something like:

    enum function { add, ... };

    // then inside your code
    switch(myfunction) {
    case add:
        return a + b;
    ...
Defunctionalisation is about removing higher-order functions, not about naming anonymous functions.

It's not a new trend, the first citation on wikipedia is to a paper in 1972.




You're focusing on my not knowing the syntax and specific of the languages. It's still just giving names to things that did not have a name. Whether the name is a variable name, a function name, a type name, doesn't matter.

It's still a fancy, obscure jargonish way of saying "name things".


There is naming but that is not the point. The point is that you turn functions into (serializable) data. Nothing fancy happening here.


Two problems I find:

1. You'll lose function inline optimizations, and also the branch predictor will get thrashed.

2. Local variables in that function essentially become globals.


I think it depends on the compiler?

In the example of that article, the only place that use the data structure is the when in the function that execute the data structure. A compiler may happily just inline it because no other where use it. And you lost no performance at all.

Or it may just decide to generate the result as it and you surely have performance problem now.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: