3 ms·
Closures, not continuations.
by pg 13y ago
Closures, not continuations.
- elwell 13y agoCould you give a quick explanation or a link that explains how that is set up? (closures stored on server) Just curious.
- wlievens 13y agoA closure is a function augmented with implicit references to the context in which it was created. In case of an upvote link it would hold references to the post you could upvote. That reference exists not in the URL but in the closure at the servers side. If you keep these objects in memory indefinitely, you'll run out of ram.
- elwell 13y agoOh, I was assuming some sort of custom implementation for doing that. If it's just hanging around in RAM, fair enough; can't see how that has scaled so well, but hey.
- wlievens 13y agoWell, a closure can't be more than a couple hundred bytes, I guess. If he wants to continue with that technique, I'd hack it like this: use reflection to crawl the closure, isolate the variables bound to the closure context, serialize those (the user id's, post id's, etc). Then the closure code, which will be one of only a few "templates", can be put into a global dictionary. The serialized state goes into the URL parameters. The closure is collected, and "reified" from the global dictionary and URL state once the user performs the action. I don't know if LISP's reflection can pull this off, but I'm pretty sure it's no biggie.