4 ms·
Whilst not supporting first class functions, C is pretty easy on you in that respect. I reckon there are suitably small lisp implementations in C (less than 10
by bwarp 15y ago
Whilst not supporting first class functions, C is pretty easy on you in that respect. I reckon there are suitably small lisp implementations in C (less than 100 lines). It all really depends if your lisp implementation uses the language's VM or a VM layer over the top.
- VMG 15y agoWhich class are functions in C? It was my impression that the only thing missing were anonymous functions, but there are pointers to functions if I'm not mistaken.
- nandemo 15y ago> Which class are functions in C? Economy class. :-) In general, how do you write functions that return functions without some form of anonymous function? For instance, how do you write a function that takes an int a and returns a function that takes an int parameter and returns non-zero if and only if that parameter is greater than a?
- bwarp 15y agoYou can use function pointers. Functions in C are not first class (they are not a type) but you can emulate higher order functions crudely using function pointers. It gets ugly pretty quick though.