In some situations, an application may want to switch namespaces temporarily using, for instance:

    Method m()
    {
        set oldNs = $namespace
        set $namespace = newNs // or: znspace newNs
        do ..something()
        set $namespace = oldNs // or: znspace oldNs
    }

But if the code between namespace changes fails for any reason, the namespace will not be switched back. The solution is to use new $namespace instead:

    Method m()
    {
        // Make any changes to $namespace private to this method
        new $namespace
        set $namespace = newNs // or: znspace newNs
        do ..something()
        // Namespace is automatically restored here
    }