FP2: Fully In-Place Functional Programming [pdf]
microsoft.com
microsoft.com
> yes! Currently the active development is in dev-fbip, see also our recent tech report: https://www.microsoft.com/en-us/research/publication/fp2-ful... We hope to put out a fresh release after the POPL deadline (Jul 11) that will include the new fip keyword and other goodies.
[0] Ctrl-f "Perceus" on the following page and you will see a paper about Koka mentioned. https://www.roc-lang.org/
More publications about Clean here: https://clean.cs.ru.nl/Publications
[1] http://www.mbsd.cs.ru.nl/publications/papers/1994/smes94-gua...
[2] http://www.mbsd.cs.ru.nl/publications/papers/1995/bare95-uni...
(I agree about Lean 4 as becoming a great general purpose language though!)
This paper (Daan is a collegue of Leo at MS Research) gives a different formalization and proofs. The file is still named "fbip.pdf" though :)
So yes, Lean 4 does use "FBIP", but "FBIP" is sort of more like an evaluation/compilation strategy, it's not any one algorithm or specific semantics. To be more precise, Lean uses Perseus, which basically has the insight "if an object's refcount is 1, I can do an in place update." You could say FIP is the natural evolution from taking a specific algorithm -- Perseus -- and sort of taking it and thinking about it from a language design POV. Perseus is the dynamic runtime implementation of FIP. But the calculus also has a static approach, too, which the paper describes using a uniqueness-typing algorithm.
These things do influence the language directly and are visible to programmers, so I don't think it's fair to say Lean 4 uses the FIP calculus described in this specific paper. For example, this semantic calculus is going to be user-visible in the next release of Koka; you'll be able to annotate functions as 'fip' or 'fbip' where the compiler will do linearity checks on the given function to guarantee that it doesn't use stack space, without needing the code generator to insert the dynamic reference counting checks required by Perseus. This also requires a notion of second-order function, stack space, etc. So it's not just some implementation detail, this is something Lean 4 would need to go out of their way to support and design for users.
I believe jq code is interpreted, so while it might be able to mutate some values in place, that doesn't mean the interpreter wouldn't allocate and release memory.
In-place updating means you re-use the memory location of an earlier variable that's not needed anymore. Simple example in pseudo-C:
BigInt increment_twice(const BigInt x) {
const BigInt y = x + 1;
const BigInt z = y + 1;
return z;
}
There are no compile-time constant expressions that could be folded here. But since y is not used after z is assigned, we can re-use the memory location of y for the memory location of z.And if the caller is not using the argument after the function returns, the memory location of the argument can be used to store the return value. This means the function call does not need to allocate memory at all, not even on the stack.