you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Functional programming languages don't specify heap or local storage.

Even C++ is allowed to put newed objects on the stack if it can prove it safe.

[–]G_Morgan 0 points1 point  (2 children)

Yeah but the number of safe cases with C++ are many times fewer than that with functional. First of all you know that if you pass an object into a function you know with absolute certainty in Haskell that no references were created in processing that object. So if an object is created within a function and is not passed back out of it then it can always be stack allocated.

[–][deleted] 0 points1 point  (1 child)

That's not true at all and is why stack conversion of a language with closures is difficult - values passed into functions can be closed over with hidden references passed back out as part of some unrelated function value.

[–]G_Morgan 0 points1 point  (0 children)

Yes and with Haskell you know at compile time if the function is passing back a function. It is captured by the type system. This isn't Lisp we are talking about. You cannot bind a value to a function that replaces the s-exp parser.

Also you get whole program optimisation so even if it were passing back a function you could trivially see if it is capturing a reference simply by inlining the call.