2 ms·
D pure functions can always allocate memory via the GC. If you don't want to use the GC it is customary to use a pure wrapper around malloc (even though you th
by mhh__ 6y ago
D pure functions can always allocate memory via the GC.
If you don't want to use the GC it is customary to use a pure wrapper around malloc (even though you theoretically shouldn't, it works fine in practice).
https://dlang.org/library/core/memory/pure_malloc.html https://dlang.org/library/core/memory/pure_malloc.html
https://run.dlang.io/is/xB0Qeu https://run.dlang.io/is/xB0Qeu this RPN calculator (the one I wrote for the dlang.org page but ungolfed) is pure and checked as such by the compiler. It's also referentially transparent because "in" means the input parameter is constant and can't escape (and thread local fyi).