Allen Wirfs-Brock allen at wirfs-brock.com
Fri Sep 16 10:41:23 PDT 2011

On Sep 16, 2011, at 5:14 AM, Andreas Rossberg wrote:
> ...

> Consider writing a server. If I cannot rely on tail call optimization
> then writing its message loop as a recursive function (e.g. actors
> style) would be incorrect. If I cannot rely on GC, then allocating an
> object for each received message would be incorrect.

But at the extreme you can't rely on GC.  Any allocation may be the one that exhausts actual available storage or triggers a interminable GC thrashing of virtual memory.  In the real world these are quality of implementation issues that developers must deal with via load testing on real implementations.

> If I cannot rely
> on weak maps, then, say, mapping every message object to a return IP
> would be incorrect.

A WeakMap reliably maintains a mapping from an object to a value.  If you have access to an object key then you can rely upon a WeakMap preserving any mappings it has for that key.  What you can not rely upon is the timely recycling of any resources that are used to represent inaccessible WeakMap mappings.  This is the exact situation that exists for any ECMAScript dynamic allocation.  There are no guarantees in the ES spec. that resources allocated with an inaccessible object  will be freed in a timely manner or ever.  Given the state of the art of memory management isn't clear how you could make such guarantees without unreasonably limiting implementors.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110916/bee23984/attachment.html>

More information about the es-discuss mailing list