3 ms·
Actually, first class functions also means the ability to form functions (ie, closures). Javascript for instance has that feature. I think that python also supp
by fstrthnscnd 5y ago
Actually, first class functions also means the ability to form functions (ie, closures). Javascript for instance has that feature. I think that python also supports it. C OTOH doesn't, but it has other advantages.
- pjmlp 5y agoBasic implementation for car, cdr, map with function pointers and clang blocks, the rest of Lispy stuff is left as an exercise. :) https://godbolt.org/z/Y5qWs4c64 https://godbolt.org/z/Y5qWs4c64
- fstrthnscnd 5y agoThat's cool! C++ had support for partial applications with templates (std::bind iirc), and it was possible to implement closures as objects with the () operator implemented. Now it has support for closure with a dedicated syntax. It would be possible to do something similar in C - a closure is just a function pointer and a bunch of parameters bundled together, but I don't think there's enough flexibility in the language to make it look like regular function calls.