5 ms·
> However, things like closures, composition at runtime and partial function application just made everything 10x harder. Closures are just functions with an e
by utterwise 3y ago
> However, things like closures, composition at runtime and partial function application just made everything 10x harder.
Closures are just functions with an extra parameter for the environment (free variables). Subsequent passes after desugaring can treat them like any other function.
Function composition and currying should also be static transformations. Maybe you made it harder than it has to be?
- tsegratis 3y agoIf functions are higher order then the distinction between plain functions and closures is retained (unless you treat all functions as closures). This is because the data needs to be passed around in the function pointer. If not higher order then yes, they desugar Implementing these things is maybe easy for you ;) but for myself, doing it well, I would definitely not describe as a walk in the park
- utterwise 3y agoIt is true you need to pass the environment around, but if the language you are implementing also has objects or structs then you will need to implement that anyway. My main objection to the grand parent is the idea that functional languages are 10x more difficult to implement than mainstream languages. Maybe that is true for Haskell, but most functional features can be compiled efficiently without much additional complexity. The complexity added by closures for instance would be closer to 1% than 10x.