Stack Scoped "Global" Variables - Is there a name for this functional pattern?
===

I use this pattern a lot:

    var scope = [];
    function getValue() {
        return scope[scope.length - 1];
    }

    function withScope(scopeValue,fn) {
        return function() {
            try {
                scope.push(scopeValue);
                return fn.apply(this,arguments);
            } finally {
                scope.pop();
            }
        };
    }


    var foo = withScope('foo',function() {
        return getValue();
    });

    var bar = withScope('bar',function() {
        return getValue() + ' ' + foo();
    });

    bar() === 'bar foo';

Does it have a name? The goal is to set some more or less "global" state for a section of the call stack. 