6 ms·
On the other hand, well-known constructs as used for translating FORTRAN labels to switch statements have been around for ages. E.g., function main(entrypoin
by masswerk 9y ago
On the other hand, well-known constructs as used for translating FORTRAN labels to switch statements have been around for ages. E.g.,
function main(entrypoint) {
switch (entrypoint) {
default:
case 0:
// do some (...)
// now drop the thread and wait for input (external)
myInputFunc(function(result) { main(1, result); });
break;
case 1:
// return to here from input
var value = arguments[1];
// now do something with it ...
break;
}
}
function myInputFunc(callback) {
// in actuality this might be servicing a more complex UI
document.querySelector('#inputField').oninput =
function() { callback(this.value); };
}
- masswerk 9y agoThis way we were porting former terminal services to web applications back in the last century ... (Maybe requesting additional server data by what would be called padded JSON nowadays via a hidden frame, because no AJAX. And, maybe, we would have rather used global vars for control than anonymous functions, but this another story.) :-)