Re: [IndexedDB] Closing on bug 9903 (collations)

On Tue, May 3, 2011 at 3:19 AM, Keean Schupke <keean@fry-it.com> wrote:
> The more I think about it, the more I want a user-specified comparison
> function. Efficiency should not be an issue here - the engines should tweek
> the JIT compiler to fix any efficiency issues. Just let the user pass a
> closure (remember functions are first-class in JavaScript so this is not a
> callback nor an event).

Wouldn't it be a bit more complicated than just passing a regular
closure?  The function has to be persisted in the database across page
views, but a JavaScript closure is going to contain references to all
sorts of objects (like document, or local variables) that are very
specific to the current page view.  It makes no sense to persist those
objects in general.  You'd need to serialize the function somehow,
possibly putting restrictions on the sorts of variables it can access,
so that it can be sensibly restored later.  Is there some established
way of doing this yet in JavaScript?  It might be useful in other
contexts too.

I still agree that this is the correct direction to go in, though.

Received on Tuesday, 3 May 2011 14:28:24 UTC