5 ms·
Pure functional programming doesn't require any special memory management beyond the stack, if it avoids any data representations that use reference semantics a
by kazinator 10y ago
Pure functional programming doesn't require any special memory management beyond the stack, if it avoids any data representations that use reference semantics and have indefinite lifetimes. Lazy evaluation and higher order functions with environment are pretty much out. But even C can be functional:
int (*pg)(int) = f();
int x = h() + 2*z;
int w = pg(y);
/* ... etc */
Here, we just introduce new variables instead of assigning new ones, don't malloc anything and indirect only by means of dumb function pointers carrying no environments.
There could be some higher level (though nonetheless quite primitive) assignment-free language for specifying tasks for the 1000 cores of this chip, instead of programming them in assembler.
- valarauca1 10y ago>Pure functional programming doesn't require any special memory management beyond the stack, Yes. Just an infinite amount of stack. Why? See my previous post. If we pretend for a minute we live in the real world... Oh guess what your stack can still over flow and assignment/binding can still fail. Also in a pure stack based language you can't preform multithreading. If you do... Well now your building a whole OoO super-scalar functional VM on top of a physical processor just to avoid doing GC.
- kazinator 10y agoInfinite stack. Why? Oh, because there is no iteration so recursion has to be used? Iteration rewrites to tail calls though; they don't require stack. As far as real tail-calls go, you avoid the algorithms that blow stacks: stick to strict divide and conquer, to keep the stack depth logarithmic. About multithreading: this language can describes a computation done by each of up to 1000 nodes. Those implicitly run in parallel.