News for hackers. Stuff that matters.
Re:Microsoft Research: Fully In-Place Functional Programming... by tuukkah on Monday June 26, 2023 @01:12AM (#36475964)
Constant folding means you calculate the result of an expression at compile time.

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.

Re:Microsoft Research: Fully In-Place Functional Programming... by jimsimmons on Monday June 26, 2023 @02:01AM (#36476222)
One is for stack allocated objects and the other for heap
Re:Microsoft Research: Fully In-Place Functional Programming... by GrygrFlzr on Monday June 26, 2023 @02:58AM (#36476577)
Does this make it more difficult to reason about the program memory usage over its lifetime, or can all potential cases be statically analyzed?
Re:Microsoft Research: Fully In-Place Functional Programming... by kmill on Monday June 26, 2023 @03:48AM (#36476887)
The paper is about trying to statically analyze this. As I understand it, fip-annotated functions are ones that are checked to neither allocate nor deallocate.
Re:Microsoft Research: Fully In-Place Functional Programming... by tuukkah on Monday June 26, 2023 @03:49AM (#36476899)
Seems easy and clear: they introduce a keyword "fip" that you use to mark a function as being fully in-place, and they statically check it.