One can return a partial function application and it looks just like any other function, so in the general case, it can't be garbage collected. This isn't special to JavaScript. In fact, JavaScript doesn't support partial function application. What JavaScript, Elm, and pretty much any other language that purports to be functional does support is capturing values through closure creation and because those closures can be returned as values, they need to be subject to garbage collection.
Mark > On Dec 13, 2017, at 2:15 AM, 'Rupert Smith' via Elm Discuss > <[email protected]> wrote: > > >> On Saturday, December 9, 2017 at 2:13:18 AM UTC, Mark Hamburg wrote: >> Functions get garbage collected. Otherwise think what would happen every >> time you use partial function application or define a function within a let >> or other nested context. Because those functions (can) capture values, they >> are new values just as much as a list or record or other data value would be. > > Is this something that is specific to the way javascript works? In my > experience partial function applications create a continuation, which is a > stack frame holding the captured values. Once the function completes the > stack frame is discarded, so there is no allocation or GC on the heap. Is > this not how Elm would be implemented on webasm and managing its own memory? > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
