public function pop($name, $last = TRUE, $emulate = null)
  {
    $name = $this->get_field_name($name);
    $this->_operations['$pop'][$name] = $last ? 1 : -1;
    if ($emulate === FALSE || ($emulate === null && $this->_emulate === FALSE))
    {
      return $this->_set_dirty($name);
    }
    else
    {
      $ref = & $this->get_field_reference($name, TRUE, null);
      if ($ref === null) return $this;
      if (!is_array($ref)) throw new MongoException("Value '$name' cannot be used as an array");
      if ($last) array_pop($ref);
      else array_shift($ref);
      return $this;
    }
  }