Loading Variables Using Continuations

Let's say I have a piece of code like this:


The var function loads the variable user/name either from a local cache or hunts for it on the net.

I was thinking that perhaps I could use continuations to avoid writing this as:

var('user/name', function(val) { $('#test').text(val) })

Except the yield method has to return a value and execution continues. That initial return value is what would be used.

The only way to make this version of var to work is to have the request execute synchronously which would block the program for every request…