On Sun, Jan 3, 2021 at 10:37 AM Olle Härstedt <olleharst...@gmail.com> wrote: > Thanks Sara! I realize I should have been more precise: Can PHP > allocate non-reference counted memory that automatically is freed when > leaving scope, similar to what Go does with escape analysis? >
It seems like you're conflating userspace variables and their underlying data storage mechanisms and while the two are related and have naturally similar semantics, they're not really the same thing and trying to generically talk about both at the same time is only going to add to confusion. If you're talking about userspace variables... Yeah. They're scope bound and destructed/freed on scope exit. Nearly every language does some form of this because to not do so would be leaky and awful. If you're talking about internal memory allocators, then the idea of "automatically freed" is a red-herring. It's an illusion created by some languages to cover up the quite explicit mechanisms in place to handle data lifetimes. PHP does its form of this as well using a combination of stack and heap allocators as appropriate. -Sara