Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Read up, you've missed a memo :-P. Plan for Harmony-era weak refs is to notify in next event loop turn.

Note turn-based notification. No way will exact GC schedule be leaked via callbacks from the GC. Ditto anything like Java's post-mortem finalization.

But your "e.g." is unclear, though. Why do you need to manually deallocate a callback function passed to setTimeout?



> Read up, you've missed a memo :-P. Plan for Harmony-era weak refs is to notify in next event loop turn.

Got a link to the memo? I haven't heard about this one.

> Why do you need to manually deallocate a callback function passed to setTimeout?

One of my use cases is running lua in the browser. see lua.vm.js: https://kripken.github.io/lua.vm.js/repl.html

When you pass a lua function to a javascript function, I create a 'proxy' object that holds a reference to the function in the lua VM. Only if javascript tells me it's "done" with it can I drop the ref inside the lua VM.


FWIW, this is exactly the same problem we had with making it possible for Embind to allow passing C++ functions into setTimeout.

We'd need to synthesize a JavaScript function that holds a wrapper object for the C++ function, and that wrapper object would need to be deallocated when the timer is done. For general callbacks, this is a hard problem, and finalizers would provide a clean way to solve it.


See, e.g.,

https://esdiscuss.org/topic/weak-event-listener#content-2

It's hard to find something fresh. I will stir the pot at the July TC39 meeting and get the committee on the record for weak refs with turn-delayed notification, or bust!


> See, e.g.,

> https://esdiscuss.org/topic/weak-event-listener#content-2

> It's hard to find something fresh. I will stir the pot at the July TC39 meeting and get the committee on the record for weak refs with turn-delayed notification, or bust!

As recently as September last year you told me it may happen... but with an indeterminate timeframe: https://mail.mozilla.org/pipermail/es-discuss/2014-September...


Yeah, it needs an active champion. I'll poke likely champs.


Weak refs are actually going in??? I got the impression they were dead because TC39 disliked them so much.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: