4 ms·
I found none of these particularly difficult. (I've never attempted 3. or 5. though.) Functional values, however, are difficult. They work effortlessly in
by DonaldFisk 9y ago
I found none of these particularly difficult. (I've never attempted 3. or 5. though.) Functional values, however, are difficult. They work effortlessly in interpreted code, but in compiled code you're faced with the upwards funarg problem: https://en.wikipedia.org/wiki/Funarg_problem#Upwards_funarg_problem https://en.wikipedia.org/wiki/Funarg_problem#Upwards_funarg_...
A solution is needed if you want lazy evaluation.
- sago 9y agoHow did you do lambdas and lexical scoping without 'functional values'?
- theoh 9y agoPresumably by implementing only the simpler "downwards" funargs: the ability to pass functions into a function scope but never return them.
- DonaldFisk 9y agoThat's explained in https://en.wikipedia.org/wiki/Funarg_problem#Downwards_funarg_problem https://en.wikipedia.org/wiki/Funarg_problem#Downwards_funar... In addition to return address and dynamic link, you need to store a static link in each stack frame.
- aarongolliver 9y ago5 is do-able by an undergrad, though the first time you encounter the concept it can be difficult to grapple how you would implement it.
- chrisseaton 9y ago> They work effortlessly in interpreted code, but in compiled code you're faced with the upwards funarg problem No it's not about interpreted or compiled. It's about using the native stack or a heap for stack frames. Compiled code and interpreters can both use either, so that's orthogonal.
- DonaldFisk 9y agoYes, to solve the upwards funarg problem you can't rely on a single stack. The problem is that using the heap for everything instead comes with a heavy computational cost, and using the heap only when you need it means you need to identify those circumstances, which isn't trivial.