|
|
|
|
|
by chriswarbo
2033 days ago
|
|
> I cannot seem to find what changes by knowing that piece of information The most common change is that writing convertion functions between 'foo(bar, baz)', 'foo(bar)(baz)' and 'foo((bar, baz))' calling conventions becomes more annoying. It's not that I find myself doing it any more or less, it's that knowing they're equivalent makes it even more frustrating. There can also be a difference in efficiency, e.g. in 'foo(bar)(baz)' we can have 'foo(bar)' pre-calculate something expensive, which will get re-used if we do things like 'f = foo(bar); f(a); f(b); f(c); myList.map(foo(baz)); etc. whilst the 'foo(bar, baz)' version will generally re-calculate such things every time. Of course, this varies depending on compiler optimisations and other language features, but the nice thing about the 'foo(bar)(baz)' version is that it can simply be a matter of scope, e.g. in Haskell: foo1 x y = let cached = expensive x
in ...
foo2 x = let cached = expensive x
in \y -> ...
We can achieve a similar result in other ways and in many languages, but many of those alternatives (e.g. 'static variables', intermediate classes, mutable variables, etc.) require much more ceremony and boilerplate. |
|
- http://galileo.phys.virginia.edu/classes/551.jvn.fall01/prim...
- https://www.forth.com/starting-forth/11-forth-compiler-defin...
- https://www.forth.com/starting-forth/9-forth-execution/
> In Forth, there is virtually no excess overhead in recursive calls because Forth uses the stack directly. So there is no reason not to recurse if that is the best way to program the algorithm.