public static function ternaryShortcut(callable $a, callable $b, Context $context)
    {
        $policy = $context->setAccessPolicy(Context::ACCESS_POLICY_RETURN_NULL);
        
        try {
            $val = $a($context);
        } finally {
            $context->setAccessPolicy($policy);
        }
        
        if ($val instanceof \Countable) {
            if ($val->count()) {
                return $val;
            }
            
            return $b($context);
        }
        
        return empty($val) ? $b($context) : $val;
    }